]> git.donarmstrong.com Git - debbugs.git/blobdiff - cgi/soap.cgi
Fix SOAP module hack to work around Date/Time encoding which broke in newer versions...
[debbugs.git] / cgi / soap.cgi
index f6b0d0410c4daeeb5f29dbd4a6a7e3ae9e0615fc..261042b0a88c5731ab3c35d9d93df704d550bca0 100755 (executable)
@@ -1,4 +1,7 @@
-#!/usr/bin/perl -wT
+#!/usr/bin/perl -T
+
+use warnings;
+use strict;
 
 #use SOAP::Transport::HTTP;
 
@@ -16,13 +19,29 @@ my $soap = Debbugs::SOAP::Server
 # soapy is stupid, and is using the 1999 schema; override it.
 *SOAP::XMLSchema1999::Serializer::as_base64Binary = \&SOAP::XMLSchema2001::Serializer::as_base64Binary;
 *SOAP::Serializer::as_anyURI       = \&SOAP::XMLSchema2001::Serializer::as_string;
+# do this twice to avoid the warning if the serializer doesn't get
+# used
+*SOAP::XMLSchema1999::Serializer::as_base64Binary = \&SOAP::XMLSchema2001::Serializer::as_base64Binary;
+*SOAP::Serializer::as_anyURI       = \&SOAP::XMLSchema2001::Serializer::as_string;
 # to work around the serializer improperly using date/time stuff
 # (Nothing in Debbugs should be looked at as if it were date/time) we
 # kill off all of the date/time related bits in the serializer.
 my $typelookup = $soap->serializer()->{_typelookup};
 for my $key (keys %{$typelookup}) {
-     next unless defined $_ and /Month|Day|Year|date|time|duration/i;
-     delete $typelookup->{$key};
+    if (defined $key and
+        $key =~ /Month|Day|Year|date|time|duration/i
+       ) {
+        # set the sub to always return 0
+        $typelookup->{$key}[1] = sub { 0 };
+    }
 }
-$soap->handle;
 
+our $warnings = '';
+eval {
+    # Ignore stupid warning because elements (hashes) can't start with
+    # numbers
+    local $SIG{__WARN__} = sub {$warnings .= $_[0] unless $_[0] =~ /Cannot encode unnamed element/};
+    $soap->handle;
+};
+die $@ if $@;
+warn $warnings if length $warnings;