]> 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:13 +0000 (08:22 +0000)
committerDmitry Stogov <dmitry@php.net>
Wed, 2 May 2007 08:22:13 +0000 (08:22 +0000)
NEWS
ext/soap/php_encoding.c
ext/soap/soap.c
ext/soap/tests/bugs/bug41097.phpt [new file with mode: 0755]

diff --git a/NEWS b/NEWS
index 2dfe0d7fc9b57a0a347fb943ca5eb196085b1e13..776e5be23face99b374d91b615d52eda4d4b9804 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,8 @@ PHP                                                                        NEWS
 ?? Apr 2007, PHP 5.2.3RC3
 - Fixed iterator_apply() with a callback using __call(). (Johannes)
 - Fixed bug #41215 (setAttribute return code reversed). (Ilia)
+- Fixed bug #41097 (ext/soap returning associative array as indexed without
+  using WSDL). (Dmitry)
 
 26 Apr 2007, PHP 5.2.2RC2
 - Added GMP_VERSION constant. (Tony)
index 2ae06a768a1b8627e1075801b5ca76a7343034cc..083b50ae40530677bb9a326a442ec5536a9eaef3 100644 (file)
@@ -3356,8 +3356,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_STRING) {
+       for (i = 0; i < count; i++) {
+               char *str_index;
+               ulong num_index;
+
+               if (zend_hash_get_current_key(Z_ARRVAL_P(array), &str_index, &num_index, 0) == HASH_KEY_IS_STRING ||
+                   num_index != i) {
                        return TRUE;
                }
                zend_hash_move_forward(Z_ARRVAL_P(array));
index 8120e8880da20744eda9dd3e951920f885db3e55..a8cc01836e6b2b7c73ee95cb91b870b15a5ef70e 100644 (file)
@@ -654,6 +654,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