]> granicus.if.org Git - php/commitdiff
Fixed bug #41097 (ext/soap returning associative array as indexed without using WSDL)
authorDmitry Stogov <dmitry@php.net>
Wed, 2 May 2007 08:22:32 +0000 (08:22 +0000)
committerDmitry Stogov <dmitry@php.net>
Wed, 2 May 2007 08:22:32 +0000 (08:22 +0000)
ext/soap/php_encoding.c
ext/soap/soap.c
ext/soap/tests/bugs/bug41097.phpt [new file with mode: 0755]
ext/soap/tests/interop/Round3/GroupD/r3_groupD_compound2_001w.phpt

index f4ca9b37bfd4ec968d968fc334c732e9171251dd..7386ccca21df0bd7298ff73e5aae4be2cf77ddf3 100644 (file)
@@ -3345,8 +3345,12 @@ static int is_map(zval *array)
        int i, count = zend_hash_num_elements(Z_ARRVAL_P(array));
 
        zend_hash_internal_pointer_reset(Z_ARRVAL_P(array));
-       for (i = 0;i < count;i++) {
-               if (zend_hash_get_current_key_type(Z_ARRVAL_P(array)) != HASH_KEY_IS_LONG) {
+       for (i = 0; i < count; i++) {
+               zstr str_index;
+               ulong num_index;
+
+               if (zend_hash_get_current_key(Z_ARRVAL_P(array), &str_index, &num_index, 0) != HASH_KEY_IS_LONG ||
+                   num_index != i) {
                        return TRUE;
                }
                zend_hash_move_forward(Z_ARRVAL_P(array));
index 6e31d97846d5fa78f4ead5625fcd697f16a210ba..c834cf6c9d711db5620a6826096a568b56ecad08 100644 (file)
@@ -853,6 +853,8 @@ PHP_MINIT_FUNCTION(soap)
        REGISTER_LONG_CONSTANT("XSD_ANYTYPE", XSD_ANYTYPE, CONST_CS | CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT("XSD_ANYXML", XSD_ANYXML, CONST_CS | CONST_PERSISTENT);
 
+       REGISTER_LONG_CONSTANT("APACHE_MAP", APACHE_MAP, CONST_CS | CONST_PERSISTENT);
+
        REGISTER_LONG_CONSTANT("SOAP_ENC_OBJECT", SOAP_ENC_OBJECT, CONST_CS | CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT("SOAP_ENC_ARRAY", SOAP_ENC_ARRAY, CONST_CS | CONST_PERSISTENT);
 
diff --git a/ext/soap/tests/bugs/bug41097.phpt b/ext/soap/tests/bugs/bug41097.phpt
new file mode 100755 (executable)
index 0000000..a9cfd14
--- /dev/null
@@ -0,0 +1,27 @@
+--TEST--
+Bug #41097 (ext/soap returning associative array as indexed without using WSDL)
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+function test($soap, $array) {
+  $soap->test($array);
+  echo (strpos($soap->__getLastRequest(), ':Map"') != false)?"Map\n":"Array\n";
+}
+
+
+$soap = new SoapClient(null, array('uri' => 'http://uri/', 'location' => 'test://', 'exceptions' => 0, 'trace' => 1));
+test($soap, array('Foo', 'Bar'));
+test($soap, array(5 => 'Foo', 10 => 'Bar'));
+test($soap, array('5' => 'Foo', '10' => 'Bar'));
+$soap->test(new SoapVar(array('Foo', 'Bar'), APACHE_MAP));
+echo (strpos($soap->__getLastRequest(), ':Map"') != false)?"Map\n":"Array\n";
+$soap->test(new SoapVar(array('Foo', 'Bar'), SOAP_ENC_ARRAY));
+echo (strpos($soap->__getLastRequest(), ':Map"') != false)?"Map\n":"Array\n";
+?>
+--EXPECT--
+Array
+Map
+Map
+Map
+Array
index 4fca0b84d15281f91458fb2a18ee8019a42fb36b..9aa448ce9e045002c4ae8563141ed2d8b1cacb16 100644 (file)
@@ -31,7 +31,7 @@ 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="http://soapinterop.org/person" xmlns:ns2="http://soapinterop.org/employee"><SOAP-ENV:Body><ns2:x_Employee><ns2:person><ns1:Name>Shane</ns1:Name><ns1:Male>true</ns1:Male></ns2:person><ns2:salary>1.0E+6</ns2:salary><ns2:ID>12345</ns2:ID></ns2:x_Employee></SOAP-ENV:Body></SOAP-ENV:Envelope>
+<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://soapinterop.org/person" xmlns:ns2="http://soapinterop.org/employee"><SOAP-ENV:Body><ns2:x_Employee><ns2:person><ns1:Name>Shane</ns1:Name><ns1:Male>true</ns1:Male></ns2:person><ns2:salary>1000000</ns2:salary><ns2:ID>12345</ns2:ID></ns2:x_Employee></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="http://soapinterop.org/person" xmlns:ns2="http://soapinterop.org/employee"><SOAP-ENV:Body><ns2:result_Employee><ns2:person><ns1:Name>Shane</ns1:Name><ns1:Male>true</ns1:Male></ns2:person><ns2:salary>1.0E+6</ns2:salary><ns2:ID>12345</ns2:ID></ns2:result_Employee></SOAP-ENV:Body></SOAP-ENV:Envelope>
+<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://soapinterop.org/person" xmlns:ns2="http://soapinterop.org/employee"><SOAP-ENV:Body><ns2:result_Employee><ns2:person><ns1:Name>Shane</ns1:Name><ns1:Male>true</ns1:Male></ns2:person><ns2:salary>1000000</ns2:salary><ns2:ID>12345</ns2:ID></ns2:result_Employee></SOAP-ENV:Body></SOAP-ENV:Envelope>
 ok