From: Dmitry Stogov Date: Wed, 2 May 2007 08:22:32 +0000 (+0000) Subject: Fixed bug #41097 (ext/soap returning associative array as indexed without using WSDL) X-Git-Tag: RELEASE_1_2_0~186 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e70145964697dded7de153e6c5779bd0fa050fd1;p=php Fixed bug #41097 (ext/soap returning associative array as indexed without using WSDL) --- diff --git a/ext/soap/php_encoding.c b/ext/soap/php_encoding.c index f4ca9b37bf..7386ccca21 100644 --- a/ext/soap/php_encoding.c +++ b/ext/soap/php_encoding.c @@ -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)); diff --git a/ext/soap/soap.c b/ext/soap/soap.c index 6e31d97846..c834cf6c9d 100644 --- a/ext/soap/soap.c +++ b/ext/soap/soap.c @@ -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 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 diff --git a/ext/soap/tests/interop/Round3/GroupD/r3_groupD_compound2_001w.phpt b/ext/soap/tests/interop/Round3/GroupD/r3_groupD_compound2_001w.phpt index 4fca0b84d1..9aa448ce9e 100644 --- a/ext/soap/tests/interop/Round3/GroupD/r3_groupD_compound2_001w.phpt +++ b/ext/soap/tests/interop/Round3/GroupD/r3_groupD_compound2_001w.phpt @@ -31,7 +31,7 @@ echo "ok\n"; ?> --EXPECT-- -Shanetrue1.0E+612345 +Shanetrue100000012345 -Shanetrue1.0E+612345 +Shanetrue100000012345 ok