summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@php.net>2007-05-02 09:38:12 +0000
committerDmitry Stogov <dmitry@php.net>2007-05-02 09:38:12 +0000
commit101a0f08ce9650b92fdce6560ad994020a3eba76 (patch)
tree9ab665f7560eddc21dad4dc5f11ac4aae2ca6c7b
parent4b7999cd0bf092fb5d1fa10050d8ac6568a22c25 (diff)
downloadphp-git-101a0f08ce9650b92fdce6560ad994020a3eba76.tar.gz
Fixed bug #41004 (minOccurs="0" and null class member variable)
-rw-r--r--NEWS1
-rw-r--r--ext/soap/php_encoding.c2
-rwxr-xr-xext/soap/tests/bugs/bug41004.phpt36
-rwxr-xr-xext/soap/tests/bugs/bug41004.wsdl69
4 files changed, 108 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index 776e5be23f..34743af934 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,7 @@ PHP NEWS
- Fixed bug #41215 (setAttribute return code reversed). (Ilia)
- Fixed bug #41097 (ext/soap returning associative array as indexed without
using WSDL). (Dmitry)
+- Fixed bug #41004 (minOccurs="0" and null class member variable). (Dmitry)
26 Apr 2007, PHP 5.2.2RC2
- Added GMP_VERSION constant. (Tony)
diff --git a/ext/soap/php_encoding.c b/ext/soap/php_encoding.c
index 083b50ae40..6a2c71d583 100644
--- a/ext/soap/php_encoding.c
+++ b/ext/soap/php_encoding.c
@@ -1595,6 +1595,8 @@ static int model_to_xml_object(xmlNodePtr node, sdlContentModelPtr model, zval *
property = xmlNewNode(NULL, BAD_CAST("BOGUS"));
xmlAddChild(node, property);
set_xsi_nil(property);
+ } else if (Z_TYPE_P(data) == IS_NULL && model->min_occurs == 0) {
+ return 1;
} else {
property = master_to_xml(enc, data, style, node);
if (property->children && property->children->content &&
diff --git a/ext/soap/tests/bugs/bug41004.phpt b/ext/soap/tests/bugs/bug41004.phpt
new file mode 100755
index 0000000000..5f359d9a6f
--- /dev/null
+++ b/ext/soap/tests/bugs/bug41004.phpt
@@ -0,0 +1,36 @@
+--TEST--
+Bug #41004 minOccurs="0" and null class member variable
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+ini_set('soap.wsdl_cache_enabled', false);
+
+class EchoBean{
+ public $mandatoryElement;
+ public $optionalElement;
+
+}
+
+class EchoRequest{
+ public $in;
+}
+
+class EchoResponse{
+ public $out;
+}
+
+$wsdl = dirname(__FILE__)."/bug41004.wsdl";
+$classmap = array('EchoBean'=>'EchoBean','echo'=>'EchoRequest','echoResponse'=>'EchoResponse');
+$client = new SoapClient($wsdl, array('location'=>'test://',"classmap" => $classmap, 'exceptions'=>0, 'trace'=>1));
+$echo=new EchoRequest();
+$in=new EchoBean();
+$in->mandatoryElement="REV";
+$in->optionalElement=NULL;
+$echo->in=$in;
+$client->echo($echo);
+echo $client->__getLastRequest();
+?>
+--EXPECT--
+<?xml version="1.0" encoding="UTF-8"?>
+<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:Formation"><SOAP-ENV:Body><ns1:echo><in><mandatoryElement>REV</mandatoryElement></in></ns1:echo></SOAP-ENV:Body></SOAP-ENV:Envelope>
diff --git a/ext/soap/tests/bugs/bug41004.wsdl b/ext/soap/tests/bugs/bug41004.wsdl
new file mode 100755
index 0000000000..d683e5d4ac
--- /dev/null
+++ b/ext/soap/tests/bugs/bug41004.wsdl
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:tns="urn:Formation" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="Formation"
+ targetNamespace="urn:Formation">
+ <wsdl:types>
+ <xsd:schema targetNamespace="urn:Formation">
+ <xsd:element name="echo">
+ <xsd:complexType>
+ <xsd:sequence> <xsd:element name="in" type="tns:EchoBean"></xsd:element>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="echoResponse">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="out" type="tns:EchoBean"></xsd:element>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:simpleType name="Product1Type">
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="REV"></xsd:enumeration>
+ <xsd:enumeration value="CLA"></xsd:enumeration>
+ </xsd:restriction>
+ </xsd:simpleType>
+
+ <xsd:complexType name="EchoBean">
+ <xsd:sequence>
+ <xsd:element name="mandatoryElement"
+ type="tns:Product1Type">
+ </xsd:element>
+ <xsd:element name="optionalElement"
+ type="tns:Product1Type" maxOccurs="1" minOccurs="0">
+ </xsd:element>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:schema>
+ </wsdl:types>
+ <wsdl:message name="echoRequest">
+ <wsdl:part name="parameters" element="tns:echo"></wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="echoResponse">
+ <wsdl:part name="parameters" element="tns:echoResponse"></wsdl:part>
+ </wsdl:message>
+ <wsdl:portType name="Formation">
+ <wsdl:operation name="echo">
+ <wsdl:input message="tns:echoRequest"></wsdl:input>
+ <wsdl:output message="tns:echoResponse"></wsdl:output>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="FormationServiceV1" type="tns:Formation"> <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" /> <wsdl:operation name="echo">
+ <soap:operation soapAction="urn:Formation/echo" />
+ <wsdl:input>
+ <soap:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="Formation">
+ <wsdl:port binding="tns:FormationServiceV1"
+ name="FormationSOAP">
+ <soap:address
+ location="http://localhost:8080/webapp/services/FormationServiceV1" />
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>