dmitry          Fri Mar  3 09:20:51 2006 UTC

  Modified files:              
    /php-src/ext/soap   php_encoding.c soap.c 
    /php-src/ext/soap/tests     classmap003.phpt 
    /php-src/ext/soap/tests/bugs        bug36575.phpt bug36575.wsdl 
                                        bug35142.phpt bug36226.phpt 
  Log:
  Fixed bug #36575 (SOAP: Incorrect complex type instantiation with hierarchies)
  
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/soap/php_encoding.c?r1=1.121&r2=1.122&diff_format=u
Index: php-src/ext/soap/php_encoding.c
diff -u php-src/ext/soap/php_encoding.c:1.121 
php-src/ext/soap/php_encoding.c:1.122
--- php-src/ext/soap/php_encoding.c:1.121       Tue Feb 21 20:12:42 2006
+++ php-src/ext/soap/php_encoding.c     Fri Mar  3 09:20:51 2006
@@ -17,7 +17,7 @@
   |          Dmitry Stogov <[EMAIL PROTECTED]>                             |
   +----------------------------------------------------------------------+
 */
-/* $Id: php_encoding.c,v 1.121 2006/02/21 20:12:42 dmitry Exp $ */
+/* $Id: php_encoding.c,v 1.122 2006/03/03 09:20:51 dmitry Exp $ */
 
 #include <time.h>
 
@@ -246,6 +246,23 @@
        *pos = '\0';
 }
 
+static encodePtr find_encoder_by_type_name(sdlPtr sdl, const char *type)
+{
+       if (sdl && sdl->encoders) {
+               HashPosition pos;
+               encodePtr *enc;
+
+               for (zend_hash_internal_pointer_reset_ex(sdl->encoders, &pos);
+                    zend_hash_get_current_data_ex(sdl->encoders, (void **) 
&enc, &pos) == SUCCESS;
+                    zend_hash_move_forward_ex(sdl->encoders, &pos)) {
+                       if (strcmp((*enc)->details.type_str, type) == 0) {
+                               return *enc;
+                       }
+               }
+       }
+       return NULL;
+}
+
 xmlNodePtr master_to_xml(encodePtr encode, zval *data, int style, xmlNodePtr 
parent)
 {
        xmlNodePtr node = NULL;
@@ -329,7 +346,12 @@
                                encodePtr enc = get_encoder(SOAP_GLOBAL(sdl), 
SOAP_GLOBAL(sdl)->target_ns, type_name);
                                if (enc) {
                                        encode = enc;
-                                       }                       
+                                       } else if (SOAP_GLOBAL(sdl)) {
+                                               enc = 
find_encoder_by_type_name(SOAP_GLOBAL(sdl), type_name);
+                                               if (enc) {
+                                                       encode = enc;
+                                               }
+                                       }
                                break;
                                }
                        }
@@ -1202,7 +1224,7 @@
 }
 
 /* Struct encode/decode */
-static zval *to_zval_object(encodeTypePtr type, xmlNodePtr data)
+static zval *to_zval_object_ex(encodeTypePtr type, xmlNodePtr data, 
zend_class_entry *pce)
 {
        zval *ret;
        xmlNodePtr trav;
@@ -1213,7 +1235,9 @@
        TSRMLS_FETCH();
 
        ce = ZEND_STANDARD_CLASS_DEF_PTR;
-       if (SOAP_GLOBAL(class_map) && type->type_str) {
+       if (pce) {
+               ce = pce;
+       } else if (SOAP_GLOBAL(class_map) && type->type_str) {
                zval             **classname;
                zend_class_entry  *tmp;
 
@@ -1256,7 +1280,20 @@
                            sdlType->encode->details.sdl_type->kind != 
XSD_TYPEKIND_SIMPLE &&
                            sdlType->encode->details.sdl_type->kind != 
XSD_TYPEKIND_LIST &&
                            sdlType->encode->details.sdl_type->kind != 
XSD_TYPEKIND_UNION) {
-                               ret = master_to_zval_int(sdlType->encode, data);
+
+                               if (ce != ZEND_STANDARD_CLASS_DEF_PTR &&
+                                   sdlType->encode->to_zval == 
sdl_guess_convert_zval &&
+                                   sdlType->encode->details.sdl_type != NULL &&
+                                   (sdlType->encode->details.sdl_type->kind == 
XSD_TYPEKIND_COMPLEX ||
+                                    sdlType->encode->details.sdl_type->kind == 
XSD_TYPEKIND_RESTRICTION ||
+                                    sdlType->encode->details.sdl_type->kind == 
XSD_TYPEKIND_EXTENSION) &&
+                                   (sdlType->encode->details.sdl_type->encode 
== NULL ||
+                                    
(sdlType->encode->details.sdl_type->encode->details.type != IS_ARRAY &&
+                                     
sdlType->encode->details.sdl_type->encode->details.type != SOAP_ENC_ARRAY))) {
+                                       ret = 
to_zval_object_ex(&sdlType->encode->details, data, ce);
+                               } else {
+                                       ret = 
master_to_zval_int(sdlType->encode, data);
+                               }
                                FIND_XML_NULL(data, ret);
                                if (get_zval_property(ret, "any" TSRMLS_CC) != 
NULL) {
                                        unset_zval_property(ret, "any" 
TSRMLS_CC);
@@ -1361,6 +1398,11 @@
        return ret;
 }
 
+static zval *to_zval_object(encodeTypePtr type, xmlNodePtr data)
+{
+       return to_zval_object_ex(type, data, NULL);
+}
+
 static int model_to_xml_object(xmlNodePtr node, sdlContentModelPtr model, zval 
*object, int style, int strict TSRMLS_DC)
 {
        switch (model->kind) {
http://cvs.php.net/viewcvs.cgi/php-src/ext/soap/soap.c?r1=1.175&r2=1.176&diff_format=u
Index: php-src/ext/soap/soap.c
diff -u php-src/ext/soap/soap.c:1.175 php-src/ext/soap/soap.c:1.176
--- php-src/ext/soap/soap.c:1.175       Thu Mar  2 14:08:04 2006
+++ php-src/ext/soap/soap.c     Fri Mar  3 09:20:51 2006
@@ -17,7 +17,7 @@
   |          Dmitry Stogov <[EMAIL PROTECTED]>                             |
   +----------------------------------------------------------------------+
 */
-/* $Id: soap.c,v 1.175 2006/03/02 14:08:04 dmitry Exp $ */
+/* $Id: soap.c,v 1.176 2006/03/03 09:20:51 dmitry Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -2197,6 +2197,7 @@
 
                        MAKE_STD_ZVAL(class_map);
                        *class_map = **tmp;
+                       INIT_PZVAL(class_map);
                        zval_copy_ctor(class_map);
 #ifdef ZEND_ENGINE_2
                        class_map->refcount--;
http://cvs.php.net/viewcvs.cgi/php-src/ext/soap/tests/classmap003.phpt?r1=1.2&r2=1.3&diff_format=u
Index: php-src/ext/soap/tests/classmap003.phpt
diff -u php-src/ext/soap/tests/classmap003.phpt:1.2 
php-src/ext/soap/tests/classmap003.phpt:1.3
--- php-src/ext/soap/tests/classmap003.phpt:1.2 Wed Feb  1 17:18:38 2006
+++ php-src/ext/soap/tests/classmap003.phpt     Fri Mar  3 09:20:51 2006
@@ -49,6 +49,6 @@
 --EXPECT--
 B Object
 (
-    [x] => 5
     [y] => 6
+    [x] => 5
 )
http://cvs.php.net/viewcvs.cgi/php-src/ext/soap/tests/bugs/bug36575.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/soap/tests/bugs/bug36575.phpt
diff -u /dev/null php-src/ext/soap/tests/bugs/bug36575.phpt:1.2
--- /dev/null   Fri Mar  3 09:20:51 2006
+++ php-src/ext/soap/tests/bugs/bug36575.phpt   Fri Mar  3 09:20:51 2006
@@ -0,0 +1,52 @@
+--TEST--
+Bug #36575 (Incorrect complex type instantiation with hierarchies)
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--INI--
+soap.wsdl_cache_enabled=0
+--FILE--
+<?php
+abstract class CT_A1 {
+       public $var1;
+}
+
+class CT_A2 extends CT_A1 {
+       public $var2;
+}
+
+class CT_A3 extends CT_A2 {
+       public $var3;
+}
+
+// returns A2 in WSDL
+function test( $a1 ) {
+       $a3 = new CT_A3();
+       $a3->var1 = $a1->var1;
+       $a3->var2 = "var two";
+       $a3->var3 = "var three";
+       return $a3;
+}
+
+$classMap = array("A1" => "CT_A1", "A2" => "CT_A2", "A3" => "CT_A3");
+
+$client = new SoapClient(dirname(__FILE__)."/bug36575.wsdl", array("trace" => 
1, "exceptions" => 0, "classmap" => $classMap));
+$a2 = new CT_A2();
+$a2->var1 = "one";
+$a2->var2 = "two";
+$client->test($a2);
+
+$soapRequest = $client->__getLastRequest();
+
+echo $soapRequest;
+
+$server = new SoapServer(dirname(__FILE__)."/bug36575.wsdl", array("classmap" 
=> $classMap));
+$server->addFunction("test");
+$server->handle($soapRequest);
+echo "ok\n";
+?>
+--EXPECT--
+<?xml version="1.0" encoding="UTF-8"?>
+<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"; 
xmlns:ns1="urn:test.soap#" xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
xmlns:ns2="urn:test.soap.types#" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"; 
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";><SOAP-ENV:Body><ns1:test><a1
 xsi:type="ns2:A2"><var1 xsi:type="xsd:string">one</var1><var2 
xsi:type="xsd:string">two</var2></a1></ns1:test></SOAP-ENV:Body></SOAP-ENV:Envelope>
+<?xml version="1.0" encoding="UTF-8"?>
+<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"; 
xmlns:ns1="urn:test.soap#" xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
xmlns:ns2="urn:test.soap.types#" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"; 
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";><SOAP-ENV:Body><ns1:testResponse><result
 xsi:type="ns2:A3"><var1 xsi:type="xsd:string">one</var1><var2 
xsi:type="xsd:string">var two</var2><var3 xsi:type="xsd:string">var 
three</var3></result></ns1:testResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
+ok
http://cvs.php.net/viewcvs.cgi/php-src/ext/soap/tests/bugs/bug36575.wsdl?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/soap/tests/bugs/bug36575.wsdl
diff -u /dev/null php-src/ext/soap/tests/bugs/bug36575.wsdl:1.2
--- /dev/null   Fri Mar  3 09:20:51 2006
+++ php-src/ext/soap/tests/bugs/bug36575.wsdl   Fri Mar  3 09:20:51 2006
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="utf-8"?>
+<definitions name="shoppingcart"
+       xmlns="http://schemas.xmlsoap.org/wsdl/";
+       xmlns:tns="urn:test.soap#" targetNamespace="urn:test.soap#"
+       xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/";
+       xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/";
+       xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/";
+       xmlns:xs="http://www.w3.org/2001/XMLSchema";
+       xmlns:types="urn:test.soap.types#">
+       <!-- all datatypes will be imported to namespace types: -->
+       <types>
+               <xs:schema
+                       xmlns:xs="http://www.w3.org/2001/XMLSchema";
+                       xmlns:soap = "http://schemas.xmlsoap.org/wsdl/soap/";
+                       xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/";
+                       
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/";
+                       xmlns:tns="urn:test.soap.types#"
+                       targetNamespace="urn:test.soap.types#">
+
+                       <xs:complexType name="A1">
+                               <xs:all>
+                                       <xs:element name="var1" 
type="xs:string" nillable="true"/>
+                               </xs:all>
+                       </xs:complexType>
+
+                       <xs:complexType name="A2">
+                               <xs:complexContent>
+                                       <xs:extension base="tns:A1">
+                                               <xs:all>
+                                                       <xs:element name="var2" 
type="xs:string" nillable="true"/>
+                                               </xs:all>
+                                       </xs:extension>
+                               </xs:complexContent>
+                       </xs:complexType>
+
+                        <xs:complexType name="A3">
+                               <xs:complexContent>
+                                       <xs:extension base="tns:A2">
+                                               <xs:all>
+                                                       <xs:element name="var3" 
type="xs:string" nillable="true"/>
+                                               </xs:all>
+                                       </xs:extension>
+                               </xs:complexContent>
+                       </xs:complexType>
+               </xs:schema>
+       </types>
+
+       <message name="test-request">
+               <part name="a1" type="types:A1"/>
+       </message>
+       <message name="test-response">
+               <part name="result" type="types:A2"/>
+       </message>
+
+       <portType name="catalog-porttype">
+               <operation name="test" parameterOrder="a1">
+                       <input name="test-request" message="tns:test-request"/>
+                       <output name="test-response" 
message="tns:test-response"/>
+               </operation>
+       </portType>
+
+       <!-- @type doesn't like tns: -->
+       <binding name="catalog-binding" type="tns:catalog-porttype">
+               <soap:binding style="rpc"
+                       transport="http://schemas.xmlsoap.org/soap/http"/>
+
+               <operation name="test">
+                       <soap:operation soapAction="urn:test.soap#test"/>
+                       <input>
+                               <soap:body use="encoded" 
namespace="urn:test.soap#"
+                               
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
+                       </input>
+                       <output>
+                               <soap:body use="encoded" 
namespace="urn:test.soap#"
+                               
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
+                       </output>
+               </operation>
+       </binding>
+
+       <service name="catalog">
+               <!-- @binding doesn't like to be tns: -->
+               <port name="catalog-port" binding="tns:catalog-binding">
+                       <soap:address location="xxxxxxxx"/>
+               </port>
+       </service>
+
+</definitions>
http://cvs.php.net/viewcvs.cgi/php-src/ext/soap/tests/bugs/bug35142.phpt?r1=1.2&r2=1.3&diff_format=u
Index: php-src/ext/soap/tests/bugs/bug35142.phpt
diff -u php-src/ext/soap/tests/bugs/bug35142.phpt:1.2 
php-src/ext/soap/tests/bugs/bug35142.phpt:1.3
--- php-src/ext/soap/tests/bugs/bug35142.phpt:1.2       Tue Nov  8 08:36:50 2005
+++ php-src/ext/soap/tests/bugs/bug35142.phpt   Fri Mar  3 09:20:51 2006
@@ -49,7 +49,7 @@
   public $audienceMemberId;
   public $timestamp;
   public $smokeStatus;
-  public $callInititator;
+  public $callInitiator;
 
   function __construct($audienceMemberId, $timestamp, $smokeStatus) {
     $this->audienceMemberId = $audienceMemberId;
@@ -98,6 +98,15 @@
   int(101)
   ["messageId"]=>
   int(12345)
+  ["source"]=>
+  string(3) "IVR"
+  ["logOnEvent"]=>
+  object(LogOnEvent)#%d (2) {
+    ["audienceMemberId"]=>
+    int(34567)
+    ["timestamp"]=>
+    string(25) "2005-11-08T11:22:07+03:00"
+  }
   ["logOffEvent"]=>
   array(2) {
     [0]=>
@@ -123,13 +132,4 @@
       string(3) "IVR"
     }
   }
-  ["logOnEvent"]=>
-  object(LogOnEvent)#%d (2) {
-    ["audienceMemberId"]=>
-    int(34567)
-    ["timestamp"]=>
-    string(25) "2005-11-08T11:22:07+03:00"
-  }
-  ["source"]=>
-  string(3) "IVR"
 }
http://cvs.php.net/viewcvs.cgi/php-src/ext/soap/tests/bugs/bug36226.phpt?r1=1.2&r2=1.3&diff_format=u
Index: php-src/ext/soap/tests/bugs/bug36226.phpt
diff -u php-src/ext/soap/tests/bugs/bug36226.phpt:1.2 
php-src/ext/soap/tests/bugs/bug36226.phpt:1.3
--- php-src/ext/soap/tests/bugs/bug36226.phpt:1.2       Thu Feb  2 11:42:12 2006
+++ php-src/ext/soap/tests/bugs/bug36226.phpt   Fri Mar  3 09:20:51 2006
@@ -50,7 +50,7 @@
   public $audienceMemberId;
   public $timestamp;
   public $smokeStatus;
-  public $callInititator;
+  public $callInitiator;
 
   function __construct($audienceMemberId, $timestamp, $smokeStatus) {
     $this->audienceMemberId = $audienceMemberId;
@@ -99,6 +99,18 @@
   int(101)
   ["messageId"]=>
   int(12345)
+  ["source"]=>
+  string(3) "IVR"
+  ["logOnEvent"]=>
+  array(1) {
+    [0]=>
+    object(LogOnEvent)#10 (2) {
+      ["audienceMemberId"]=>
+      int(34567)
+      ["timestamp"]=>
+      string(25) "2005-11-08T11:22:07+03:00"
+    }
+  }
   ["logOffEvent"]=>
   array(2) {
     [0]=>
@@ -124,16 +136,4 @@
       string(3) "IVR"
     }
   }
-  ["logOnEvent"]=>
-  array(1) {
-    [0]=>
-    object(LogOnEvent)#10 (2) {
-      ["audienceMemberId"]=>
-      int(34567)
-      ["timestamp"]=>
-      string(25) "2005-11-08T11:22:07+03:00"
-    }
-  }
-  ["source"]=>
-  string(3) "IVR"
 }

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to