dmitry          Fri Aug 31 10:48:57 2007 UTC

  Modified files:              
    /php-src/ext/soap   php_schema.c soap.c 
    /php-src/ext/soap/tests/bugs        bug42359.phpt bug42359.wsdl 
  Log:
  Fixed bug #42359 (xsd:list type not parsed)
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/soap/php_schema.c?r1=1.70&r2=1.71&diff_format=u
Index: php-src/ext/soap/php_schema.c
diff -u php-src/ext/soap/php_schema.c:1.70 php-src/ext/soap/php_schema.c:1.71
--- php-src/ext/soap/php_schema.c:1.70  Thu Feb 15 17:00:52 2007
+++ php-src/ext/soap/php_schema.c       Fri Aug 31 10:48:57 2007
@@ -17,7 +17,7 @@
   |          Dmitry Stogov <[EMAIL PROTECTED]>                             |
   +----------------------------------------------------------------------+
 */
-/* $Id: php_schema.c,v 1.70 2007/02/15 17:00:52 dmitry Exp $ */
+/* $Id: php_schema.c,v 1.71 2007/08/31 10:48:57 dmitry Exp $ */
 
 #include "php_soap.h"
 #include "libxml/uri.h"
@@ -453,7 +453,14 @@
                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 @@
                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 @@
                        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 @@
                        }
                        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;
http://cvs.php.net/viewvc.cgi/php-src/ext/soap/soap.c?r1=1.227&r2=1.228&diff_format=u
Index: php-src/ext/soap/soap.c
diff -u php-src/ext/soap/soap.c:1.227 php-src/ext/soap/soap.c:1.228
--- php-src/ext/soap/soap.c:1.227       Fri Aug 31 09:36:14 2007
+++ php-src/ext/soap/soap.c     Fri Aug 31 10:48:57 2007
@@ -17,7 +17,7 @@
   |          Dmitry Stogov <[EMAIL PROTECTED]>                             |
   +----------------------------------------------------------------------+
 */
-/* $Id: soap.c,v 1.227 2007/08/31 09:36:14 dmitry Exp $ */
+/* $Id: soap.c,v 1.228 2007/08/31 10:48:57 dmitry Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -3253,8 +3253,8 @@
                        while (zend_hash_get_current_data_ex(sdl->types, (void 
**)&type, &pos) != FAILURE) {
                                type_to_string((*type), &buf, 0);
                                add_next_index_rt_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);
                        }
                }
        }
@@ -5016,8 +5016,6 @@
 
        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, ' ');
@@ -5026,6 +5024,40 @@
                        }
                        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:
http://cvs.php.net/viewvc.cgi/php-src/ext/soap/tests/bugs/bug42359.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/soap/tests/bugs/bug42359.phpt
diff -u /dev/null php-src/ext/soap/tests/bugs/bug42359.phpt:1.2
--- /dev/null   Fri Aug 31 10:48:57 2007
+++ php-src/ext/soap/tests/bugs/bug42359.phpt   Fri Aug 31 10:48:57 2007
@@ -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}
+)
+
http://cvs.php.net/viewvc.cgi/php-src/ext/soap/tests/bugs/bug42359.wsdl?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/soap/tests/bugs/bug42359.wsdl
diff -u /dev/null php-src/ext/soap/tests/bugs/bug42359.wsdl:1.2
--- /dev/null   Fri Aug 31 10:48:57 2007
+++ php-src/ext/soap/tests/bugs/bug42359.wsdl   Fri Aug 31 10:48:57 2007
@@ -0,0 +1,58 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<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/";>
+  <types>
+    <xsd:schema xmlns="http://www.w3.org/2001/XMLSchema"; 
targetNamespace="urn:listTest">
+      <xsd:simpleType name="listItem">
+          <xsd:list>
+              <xsd:simpleType>
+            <xsd:restriction base="xsd:string">
+              <xsd:enumeration value="test1" />
+              <xsd:enumeration value="test2" />
+            </xsd:restriction>
+          </xsd:simpleType>
+        </xsd:list>
+      </xsd:simpleType>
+      <xsd:simpleType name="enumItem">
+        <xsd:restriction base="xsd:string">
+          <xsd:enumeration value="test1" />
+          <xsd:enumeration value="test2" />
+        </xsd:restriction>
+      </xsd:simpleType>
+      <xsd:simpleType name="listItem2">
+        <xsd:list itemType="typens:enumItem"/>
+      </xsd:simpleType>
+    </xsd:schema>
+  </types>
+  <message name="testRequest">
+    <part name="item" type="typens:listItem"/>
+  </message>
+  <message name="testRequestResponse">
+    <part name="testRequestReturn" type="xsd:integer"/>
+  </message>
+  <portType name="listTestPortType">
+    <operation name="testRequest">
+      <documentation>
+        Test request
+      </documentation>
+      <input message="typens:testRequest"/>
+      <output message="typens:testRequestResponse"/>
+    </operation>
+  </portType>
+  <binding name="listTestBinding" type="typens:listTestPortType">
+    <soap:binding style="rpc" 
transport="http://schemas.xmlsoap.org/soap/http"/>
+    <operation name="testRequest">
+      <soap:operation soapAction="urn:listTestAction"/>
+      <input>
+        <soap:body namespace="urn:listTest" use="encoded" 
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
+      </input>
+      <output>
+        <soap:body namespace="urn:listTest" use="encoded" 
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
+      </output>
+    </operation>
+  </binding>
+  <service name="listTestService">
+    <port name="listTestPort" binding="typens:listTestBinding">
+      <soap:address location="http://test/service"/>
+    </port>
+  </service>
+</definitions>

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

Reply via email to