From: mkanat%bugzilla.org <> Date: Mon, 18 May 2009 21:31:38 +0000 (+0000) Subject: Bug 477593: Make the WebService send for undef values X-Git-Tag: bugzilla-3.4rc1~34 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0155e8c5015fba4891f792624709d25aca27fe55;p=thirdparty%2Fbugzilla.git Bug 477593: Make the WebService send for undef values Patch by Rosie Clarkson r=mkanat, a=mkanat --- diff --git a/Bugzilla/WebService.pm b/Bugzilla/WebService.pm index 735291fc34..eddc6c24c0 100755 --- a/Bugzilla/WebService.pm +++ b/Bugzilla/WebService.pm @@ -269,11 +269,18 @@ Normally, XML-RPC does not allow empty values for C, C, or C fields. Bugzilla does--it treats empty values as C (called C or C in some programming languages). -Bugzilla also accepts a type called C<< >>, which is always considered -to be C, no matter what it contains. +Bugzilla also accepts an element called C<< >>, as specified by +the XML-RPC extension here: L, +which is always considered to be C, no matter what it contains. + +Bugzilla uses C<< >> values to return C, C, or +C values which are undefined. =begin private -nil is implemented by XMLRPC::Lite, in XMLRPC::Deserializer::decode_value. +nil is implemented by XMLRPC::Lite, in XMLRPC::Deserializer::decode_value +in the CPAN SVN since 14th Dec 2008 +L and in Fedora's +perl-SOAP-Lite package in versions 0.68-1 and above. =end private diff --git a/Bugzilla/WebService/Server/XMLRPC.pm b/Bugzilla/WebService/Server/XMLRPC.pm index 36b4e01fd5..2b30bea817 100644 --- a/Bugzilla/WebService/Server/XMLRPC.pm +++ b/Bugzilla/WebService/Server/XMLRPC.pm @@ -14,6 +14,9 @@ # # Contributor(s): Marc Schumann # Max Kanat-Alexander +# Rosie Clarkson +# +# Portions © Crown copyright 2009 - Rosie Clarkson (development@planningportal.gov.uk) for the Planning Portal package Bugzilla::WebService::Server::XMLRPC; @@ -167,4 +170,35 @@ sub as_string { return $self->SUPER::as_string($value); } +# Here the XMLRPC::Serializer is extended to use the XMLRPC nil extension. +sub encode_object { + my $self = shift; + my @encoded = $self->SUPER::encode_object(@_); + + return $encoded[0]->[0] eq 'nil' + ? ['value', {}, [@encoded]] + : @encoded; +} + +sub BEGIN { + no strict 'refs'; + for my $type (qw(double i4 int dateTime)) { + my $method = 'as_' . $type; + *$method = sub { + my ($self, $value) = @_; + if (!defined($value)) { + return as_nil(); + } + else { + my $super_method = "SUPER::$method"; + return $self->$super_method($value); + } + } + } +} + +sub as_nil { + return ['nil', {}]; +} + 1;