]> granicus.if.org Git - php/commitdiff
Fixed bug #44882 (SOAP extension object decoding bug)
authorDmitry Stogov <dmitry@php.net>
Thu, 27 Nov 2008 14:49:56 +0000 (14:49 +0000)
committerDmitry Stogov <dmitry@php.net>
Thu, 27 Nov 2008 14:49:56 +0000 (14:49 +0000)
ext/soap/php_encoding.c
ext/soap/tests/bugs/bug44882.phpt [new file with mode: 0644]
ext/soap/tests/bugs/bug44882.wsdl [new file with mode: 0644]

index bcbc623bd5bcaafbd4f0096c5dc2d72b400c6c7f..2bba8acfa54113d28e3e95f9e43570ce0adc5c56 100644 (file)
@@ -1458,7 +1458,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) {
@@ -1530,10 +1530,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;
@@ -1559,10 +1556,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) {
+                               Z_ADDREF_P(redo_any);
+                               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 (file)
index 0000000..366ddde
--- /dev/null
@@ -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, $one_way = 0)
+       {
+               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 (file)
index 0000000..266f6a0
--- /dev/null
@@ -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>