diff options
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | ext/soap/php_encoding.c | 20 | ||||
-rw-r--r-- | ext/soap/tests/bugs/bug44882.phpt | 64 | ||||
-rw-r--r-- | ext/soap/tests/bugs/bug44882.wsdl | 75 |
4 files changed, 152 insertions, 8 deletions
@@ -11,6 +11,7 @@ PHP NEWS (Ilia) - Fixed bug #46427 (SoapClient() stumbles over its "stream_context" parameter). (Dmitry, Herman Radtke) +- Fixed bug #44882 (SOAP extension object decoding bug). (Dmitry) - Fixed bug #44182 (extract($a, EXTR_REFS) can fail to split copy-on-write references). (robin_fernandes at uk dot ibm dot com) - Fixed bug #44181 (extract($a, EXTR_OVERWRITE|EXTR_REFS) can fail to create diff --git a/ext/soap/php_encoding.c b/ext/soap/php_encoding.c index 656759e295..62155db39b 100644 --- a/ext/soap/php_encoding.c +++ b/ext/soap/php_encoding.c @@ -1419,7 +1419,7 @@ static zval *to_zval_object_ex(encodeTypePtr type, xmlNodePtr data, zend_class_e sdlPtr sdl; sdlTypePtr sdlType = type->sdl_type; zend_class_entry *ce = ZEND_STANDARD_CLASS_DEF_PTR; - zend_bool redo_any = 0; + zval *redo_any = NULL; TSRMLS_FETCH(); if (pce) { @@ -1491,10 +1491,7 @@ static zval *to_zval_object_ex(encodeTypePtr type, xmlNodePtr data, zend_class_e if (soap_check_xml_ref(&ret, data TSRMLS_CC)) { return ret; } - if (get_zval_property(ret, "any" TSRMLS_CC) != NULL) { - unset_zval_property(ret, "any" TSRMLS_CC); - redo_any = 1; - } + redo_any = get_zval_property(ret, "any" TSRMLS_CC); if (Z_TYPE_P(ret) == IS_OBJECT && ce != ZEND_STANDARD_CLASS_DEF_PTR) { zend_object *zobj = zend_objects_get_address(ret TSRMLS_CC); zobj->ce = ce; @@ -1520,10 +1517,17 @@ static zval *to_zval_object_ex(encodeTypePtr type, xmlNodePtr data, zend_class_e object_init_ex(ret, ce); } if (sdlType->model) { + if (redo_any) { + redo_any->refcount++; + unset_zval_property(ret, "any" TSRMLS_CC); + } model_to_zval_object(ret, sdlType->model, data, sdl TSRMLS_CC); - if (redo_any && get_zval_property(ret, "any" TSRMLS_CC) == NULL) { - model_to_zval_any(ret, data->children TSRMLS_CC); - } + if (redo_any) { + if (get_zval_property(ret, "any" TSRMLS_CC) == NULL) { + model_to_zval_any(ret, data->children TSRMLS_CC); + } + zval_ptr_dtor(&redo_any); + } } if (sdlType->attributes) { sdlAttributePtr *attr; diff --git a/ext/soap/tests/bugs/bug44882.phpt b/ext/soap/tests/bugs/bug44882.phpt new file mode 100644 index 0000000000..baad747844 --- /dev/null +++ b/ext/soap/tests/bugs/bug44882.phpt @@ -0,0 +1,64 @@ +--TEST-- +Bug #44882 (SOAP extension object decoding bug) +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--INI-- +soap.wsdl_cache_enabled=0 +--FILE-- +<?php +class TestSoapClient extends SoapClient +{ + public function __doRequest($req, $loc, $act, $ver, $oneway) + { + return <<<XML +<?xml version="1.0" encoding="UTF-8"?> +<SOAP-ENV:Envelope + xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:ns="urn:ebay:api:PayPalAPI"> + <SOAP-ENV:Body id="_0"> + <GetExpressCheckoutDetailsResponse xmlns="urn:ebay:api:PayPalAPI"> + <Timestamp>2008-06-23T14:51:08Z</Timestamp> + <Ack>Success</Ack> + <CorrelationID>ae013a0ccdf13</CorrelationID> + <Version>50.000000</Version> + <Build>588340</Build> + <GetExpressCheckoutDetailsResponseDetails xsi:type="ns:GetExpressCheckoutDetailsResponseDetailsType"> + <Token>EC-11Y75137T2399952C</Token> + <PayerInfo> + <Payer>example@example.com</Payer> + <PayerID>MU82WA43YXM9C</PayerID> + <PayerStatus>verified</PayerStatus> + </PayerInfo> + </GetExpressCheckoutDetailsResponseDetails> + </GetExpressCheckoutDetailsResponse> + </SOAP-ENV:Body> +</SOAP-ENV:Envelope> +XML; + } +} + +$client = new TestSoapClient(dirname(__FILE__).'/bug44882.wsdl'); +print_r($client->GetExpressCheckoutDetails()); +?> +--EXPECT-- +stdClass Object +( + [Timestamp] => 2008-06-23T14:51:08Z + [Ack] => Success + [CorrelationID] => ae013a0ccdf13 + [Version] => 50.000000 + [Build] => 588340 + [GetExpressCheckoutDetailsResponseDetails] => stdClass Object + ( + [Token] => EC-11Y75137T2399952C + [PayerInfo] => stdClass Object + ( + [Payer] => example@example.com + [PayerID] => MU82WA43YXM9C + [PayerStatus] => verified + ) + + ) + +) diff --git a/ext/soap/tests/bugs/bug44882.wsdl b/ext/soap/tests/bugs/bug44882.wsdl new file mode 100644 index 0000000000..266f6a05b4 --- /dev/null +++ b/ext/soap/tests/bugs/bug44882.wsdl @@ -0,0 +1,75 @@ +<?xml version="1.0" encoding="UTF-8"?> +<wsdl:definitions + xmlns="http://schemas.xmlsoap.org/wsdl/" + xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" + xmlns:xs="http://www.w3.org/2001/XMLSchema" + xmlns:ns="urn:ebay:api:PayPalAPI" + xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" + targetNamespace="urn:ebay:api:PayPalAPI"> + <wsdl:types> + <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:ebay:api:PayPalAPI" elementFormDefault="qualified" attributeFormDefault="unqualified"> + <complexType name="PayerInfoType"> + <sequence> + <element name="Payer" type="xs:string" minOccurs="0"/> + <element name="PayerID" type="xs:string" minOccurs="0"/> + <element name="PayerStatus" type="xs:string" minOccurs="0"/> + </sequence> + </complexType> + <complexType name="AbstractResponseType" abstract="true"> + <sequence> + <element name="Timestamp" type="xs:dateTime" minOccurs="0"/> + <element name="Ack" type="xs:string"/> + <element name="CorrelationID" type="xs:string" minOccurs="0"/> + <element name="Version" type="xs:string"/> + <element name="Build" type="xs:string"/> + <any processContents="lax" minOccurs="0"/> + </sequence> + </complexType> + <xs:element name="GetExpressCheckoutDetailsResponseDetails" type="ns:GetExpressCheckoutDetailsResponseDetailsType"/> + <xs:complexType name="GetExpressCheckoutDetailsResponseDetailsType"> + <xs:sequence> + <xs:element name="Token" type="xs:string"/> + <xs:element name="PayerInfo" type="ns:PayerInfoType"/> + </xs:sequence> + </xs:complexType> + <xs:element name="GetExpressCheckoutDetailsResponse" type="ns:GetExpressCheckoutDetailsResponseType"/> + <xs:complexType name="GetExpressCheckoutDetailsResponseType"> + <xs:complexContent> + <xs:extension base="ns:AbstractResponseType"> + <xs:sequence> + <xs:element ref="ns:GetExpressCheckoutDetailsResponseDetails" minOccurs="1" maxOccurs="1"/> + </xs:sequence> + </xs:extension> + </xs:complexContent> + </xs:complexType> + </schema> + </wsdl:types> + <wsdl:message name="GetExpressCheckoutDetailsRequest"> + </wsdl:message> + <wsdl:message name="GetExpressCheckoutDetailsResponse"> + <wsdl:part name="GetExpressCheckoutDetailsResponse" element="ns:GetExpressCheckoutDetailsResponse"/> + </wsdl:message> + <wsdl:portType name="PayPalAPIAAInterface"> + <wsdl:operation name="GetExpressCheckoutDetails"> + <wsdl:input message="ns:GetExpressCheckoutDetailsRequest"/> + <wsdl:output message="ns:GetExpressCheckoutDetailsResponse"/> + </wsdl:operation> + </wsdl:portType> + <wsdl:binding name="PayPalAPIAASoapBinding" type="ns:PayPalAPIAAInterface"> + <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> + <wsdl:operation name="GetExpressCheckoutDetails"> + <wsdlsoap:operation/> + <wsdl:input> + <wsdlsoap:body use="literal"/> + </wsdl:input> + <wsdl:output> + <wsdlsoap:body use="literal"/> + </wsdl:output> + </wsdl:operation> + </wsdl:binding> + <wsdl:service name="PayPalAPIInterfaceService"> + <wsdl:port name="PayPalAPIAA" binding="ns:PayPalAPIAASoapBinding"> + <wsdlsoap:address location="test://"/> + </wsdl:port> + </wsdl:service> +</wsdl:definitions> |