From: Dmitry Stogov Date: Wed, 2 May 2007 08:22:13 +0000 (+0000) Subject: Fixed bug #41097 (ext/soap returning associative array as indexed without using WSDL) X-Git-Tag: php-5.2.2~9 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3721cb9d8d25054b657a4d476ceb8dcec935e46c;p=php Fixed bug #41097 (ext/soap returning associative array as indexed without using WSDL) --- diff --git a/NEWS b/NEWS index 2dfe0d7fc9..776e5be23f 100644 --- 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) diff --git a/ext/soap/php_encoding.c b/ext/soap/php_encoding.c index 2ae06a768a..083b50ae40 100644 --- a/ext/soap/php_encoding.c +++ b/ext/soap/php_encoding.c @@ -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)); diff --git a/ext/soap/soap.c b/ext/soap/soap.c index 8120e8880d..a8cc01836e 100644 --- a/ext/soap/soap.c +++ b/ext/soap/soap.c @@ -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 index 0000000000..a9cfd14140 --- /dev/null +++ b/ext/soap/tests/bugs/bug41097.phpt @@ -0,0 +1,27 @@ +--TEST-- +Bug #41097 (ext/soap returning associative array as indexed without using WSDL) +--SKIPIF-- + +--FILE-- +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