]> granicus.if.org Git - php/commitdiff
Fixed bug #42359 (xsd:list type not parsed)
authorDmitry Stogov <dmitry@php.net>
Fri, 31 Aug 2007 10:48:45 +0000 (10:48 +0000)
committerDmitry Stogov <dmitry@php.net>
Fri, 31 Aug 2007 10:48:45 +0000 (10:48 +0000)
NEWS
ext/soap/php_schema.c
ext/soap/soap.c
ext/soap/tests/bugs/bug42359.phpt [new file with mode: 0755]
ext/soap/tests/bugs/bug42359.wsdl [new file with mode: 0755]

diff --git a/NEWS b/NEWS
index 063e27ed5cbcb10bf495a4bde7fbe9a2926fda64..27bf9e96f7a1c3856598380287a4447fc5e82342 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,7 @@ PHP                                                                        NEWS
   DOMElement). (Rob)
 - Fixed bug #42452 (PDO classes do not expose Reflection API information).
   (Hannes)
+- Fixed bug #42359 (xsd:list type not parsed). (Dmitry)
 - Fixed bug #42326 (SoapServer crash). (Dmitry)
 - Fixed bug #42086 (SoapServer return Procedure '' not present for WSIBasic
   compliant wsdl). (Dmitry)
index 9ba4f81604668b68e5795ad58af1a1cdc4e1baad..0ae65ba39eb7443f8863fc85c399b2ed1aef5f3c 100644 (file)
@@ -453,7 +453,14 @@ static int schema_list(sdlPtr sdl, xmlAttrPtr tns, xmlNodePtr listType, sdlTypeP
                newType = emalloc(sizeof(sdlType));
                memset(newType, 0, sizeof(sdlType));
 
-               newType->name = estrdup("anonymous");
+               {
+                       smart_str anonymous = {0};
+                       
+                       smart_str_appendl(&anonymous, "anonymous", sizeof("anonymous")-1);
+                       smart_str_append_long(&anonymous, zend_hash_num_elements(sdl->types));
+                       smart_str_0(&anonymous);
+                       newType->name = anonymous.c;
+               }
                newType->namens = estrdup((char*)tns->children->content);
 
                if (cur_type->elements == NULL) {
@@ -463,6 +470,7 @@ static int schema_list(sdlPtr sdl, xmlAttrPtr tns, xmlNodePtr listType, sdlTypeP
                zend_hash_next_index_insert(cur_type->elements, &newType, sizeof(sdlTypePtr), (void **)&tmp);
 
                schema_simpleType(sdl, tns, trav, newType);
+
                trav = trav->next;
        }
        if (trav != NULL) {
@@ -541,7 +549,14 @@ static int schema_union(sdlPtr sdl, xmlAttrPtr tns, xmlNodePtr unionType, sdlTyp
                        newType = emalloc(sizeof(sdlType));
                        memset(newType, 0, sizeof(sdlType));
 
-                       newType->name = estrdup("anonymous");
+                       {
+                               smart_str anonymous = {0};
+                       
+                               smart_str_appendl(&anonymous, "anonymous", sizeof("anonymous")-1);
+                               smart_str_append_long(&anonymous, zend_hash_num_elements(sdl->types));
+                               smart_str_0(&anonymous);
+                               newType->name = anonymous.c;
+                       }
                        newType->namens = estrdup((char*)tns->children->content);
 
                        if (cur_type->elements == NULL) {
@@ -1879,7 +1894,14 @@ static int schema_attribute(sdlPtr sdl, xmlAttrPtr tns, xmlNodePtr attrType, sdl
                        }
                        dummy_type = emalloc(sizeof(sdlType));
                        memset(dummy_type, 0, sizeof(sdlType));
-                       dummy_type->name = estrdup("anonymous");
+                       {
+                               smart_str anonymous = {0};
+                       
+                               smart_str_appendl(&anonymous, "anonymous", sizeof("anonymous")-1);
+                               smart_str_append_long(&anonymous, zend_hash_num_elements(sdl->types));
+                               smart_str_0(&anonymous);
+                               dummy_type->name = anonymous.c;
+                       }
                        dummy_type->namens = estrdup((char*)tns->children->content);
                        schema_simpleType(sdl, tns, trav, dummy_type);
                        newAttr->encode = dummy_type->encode;
index a27626110ef5fae146f3ba06892f4c7b01306012..87d2b43056c88bd1f7cac235245da6f4af83f428 100644 (file)
@@ -2878,8 +2878,8 @@ PHP_METHOD(SoapClient, __getTypes)
                        while (zend_hash_get_current_data_ex(sdl->types, (void **)&type, &pos) != FAILURE) {
                                type_to_string((*type), &buf, 0);
                                add_next_index_stringl(return_value, buf.c, buf.len, 1);
-                               zend_hash_move_forward_ex(sdl->types, &pos);
                                smart_str_free(&buf);
+                               zend_hash_move_forward_ex(sdl->types, &pos);
                        }
                }
        }
@@ -4546,8 +4546,6 @@ static void type_to_string(sdlTypePtr type, smart_str *buf, int level)
 
        switch (type->kind) {
                case XSD_TYPEKIND_SIMPLE:
-               case XSD_TYPEKIND_LIST:
-               case XSD_TYPEKIND_UNION:
                        if (type->encode) {
                                smart_str_appendl(buf, type->encode->details.type_str, strlen(type->encode->details.type_str));
                                smart_str_appendc(buf, ' ');
@@ -4556,6 +4554,40 @@ static void type_to_string(sdlTypePtr type, smart_str *buf, int level)
                        }
                        smart_str_appendl(buf, type->name, strlen(type->name));
                        break;
+               case XSD_TYPEKIND_LIST:
+                       smart_str_appendl(buf, "list ", 5);
+                       smart_str_appendl(buf, type->name, strlen(type->name));
+                       if (type->elements) {
+                               sdlTypePtr *item_type;
+
+                               smart_str_appendl(buf, " {", 2);
+                               zend_hash_internal_pointer_reset_ex(type->elements, &pos);
+                               if (zend_hash_get_current_data_ex(type->elements, (void **)&item_type, &pos) != FAILURE) {
+                                       smart_str_appendl(buf, (*item_type)->name, strlen((*item_type)->name));
+                               }
+                               smart_str_appendc(buf, '}');
+                       }
+                       break;
+               case XSD_TYPEKIND_UNION:
+                       smart_str_appendl(buf, "union ", 6);
+                       smart_str_appendl(buf, type->name, strlen(type->name));
+                       if (type->elements) {
+                               sdlTypePtr *item_type;
+                               int first = 0;
+
+                               smart_str_appendl(buf, " {", 2);
+                               zend_hash_internal_pointer_reset_ex(type->elements, &pos);
+                               while (zend_hash_get_current_data_ex(type->elements, (void **)&item_type, &pos) != FAILURE) {
+                                       if (!first) {
+                                               smart_str_appendc(buf, ',');
+                                               first = 0;
+                                       }
+                                       smart_str_appendl(buf, (*item_type)->name, strlen((*item_type)->name));
+                                       zend_hash_move_forward_ex(type->elements, &pos);
+                               }
+                               smart_str_appendc(buf, '}');
+                       }
+                       break;
                case XSD_TYPEKIND_COMPLEX:
                case XSD_TYPEKIND_RESTRICTION:
                case XSD_TYPEKIND_EXTENSION:
diff --git a/ext/soap/tests/bugs/bug42359.phpt b/ext/soap/tests/bugs/bug42359.phpt
new file mode 100755 (executable)
index 0000000..94738ff
--- /dev/null
@@ -0,0 +1,20 @@
+--TEST--
+Bug #42326 (SoapServer crash)
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--INI--
+soap.wsdl_cache_enabled=0
+--FILE--
+<?php
+$soap = new SoapClient(dirname(__FILE__)."/bug42359.wsdl");
+print_r($soap->__getTypes());
+?>
+--EXPECT--
+Array
+(
+    [0] => list listItem {anonymous1}
+    [1] => string anonymous1
+    [2] => string enumItem
+    [3] => list listItem2 {enumItem}
+)
+
diff --git a/ext/soap/tests/bugs/bug42359.wsdl b/ext/soap/tests/bugs/bug42359.wsdl
new file mode 100755 (executable)
index 0000000..bc73ada
--- /dev/null
@@ -0,0 +1,58 @@
+<?xml version='1.0' encoding='UTF-8'?>\r
+<definitions name="listTest" targetNamespace="urn:listTest" xmlns:typens="urn:listTest" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/">\r
+  <types>\r
+    <xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:listTest">\r
+      <xsd:simpleType name="listItem">\r
+          <xsd:list>\r
+              <xsd:simpleType>\r
+            <xsd:restriction base="xsd:string">\r
+              <xsd:enumeration value="test1" />\r
+              <xsd:enumeration value="test2" />\r
+            </xsd:restriction>\r
+          </xsd:simpleType>\r
+        </xsd:list>\r
+      </xsd:simpleType>\r
+      <xsd:simpleType name="enumItem">\r
+        <xsd:restriction base="xsd:string">\r
+          <xsd:enumeration value="test1" />\r
+          <xsd:enumeration value="test2" />\r
+        </xsd:restriction>\r
+      </xsd:simpleType>\r
+      <xsd:simpleType name="listItem2">\r
+        <xsd:list itemType="typens:enumItem"/>\r
+      </xsd:simpleType>\r
+    </xsd:schema>\r
+  </types>\r
+  <message name="testRequest">\r
+    <part name="item" type="typens:listItem"/>\r
+  </message>\r
+  <message name="testRequestResponse">\r
+    <part name="testRequestReturn" type="xsd:integer"/>\r
+  </message>\r
+  <portType name="listTestPortType">\r
+    <operation name="testRequest">\r
+      <documentation>\r
+        Test request\r
+      </documentation>\r
+      <input message="typens:testRequest"/>\r
+      <output message="typens:testRequestResponse"/>\r
+    </operation>\r
+  </portType>\r
+  <binding name="listTestBinding" type="typens:listTestPortType">\r
+    <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>\r
+    <operation name="testRequest">\r
+      <soap:operation soapAction="urn:listTestAction"/>\r
+      <input>\r
+        <soap:body namespace="urn:listTest" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>\r
+      </input>\r
+      <output>\r
+        <soap:body namespace="urn:listTest" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>\r
+      </output>\r
+    </operation>\r
+  </binding>\r
+  <service name="listTestService">\r
+    <port name="listTestPort" binding="typens:listTestBinding">\r
+      <soap:address location="http://test/service"/>\r
+    </port>\r
+  </service>\r
+</definitions>\r