From: Derick Rethans Date: Wed, 7 Jan 2009 14:36:49 +0000 (+0000) Subject: - MFH: Fixed bug #47027 (var_export doesn't show numeric indices on ArrayObject). X-Git-Tag: php-5.2.9RC1~155 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3c15c0089182c27d2d823bc12a9474a795dbc363;p=php - MFH: Fixed bug #47027 (var_export doesn't show numeric indices on ArrayObject). --- diff --git a/NEWS b/NEWS index 01ef2d7a18..a1b51b0278 100644 --- a/NEWS +++ b/NEWS @@ -11,6 +11,8 @@ PHP NEWS (Fixes CVE-2008-5498) (Scott) - Fixed a segfault when malformed string is passed to json_decode(). (Scott) +- Fixed bug #47027 (var_export doesn't show numeric indices on ArrayObject). + (Derick) - Fixed bug #46985 (OVERWRITE and binary mode does not work, regression introduced in 5.2.8). (Pierre) - Fixed bug #46973 (IPv6 address filter rejects valid address). (Felipe) diff --git a/ext/standard/tests/general_functions/bug47027.phpt b/ext/standard/tests/general_functions/bug47027.phpt new file mode 100644 index 0000000000..e4f5aae9dd --- /dev/null +++ b/ext/standard/tests/general_functions/bug47027.phpt @@ -0,0 +1,12 @@ +--TEST-- +Bug #47027 (var_export doesn't show numeric indices on ArrayObject) +--FILE-- + "foo", "bar" => "baz")); +var_export ($ao); +?> +--EXPECT-- +ArrayObject::__set_state(array( + 2 => 'foo', + 'bar' => 'baz', +)) diff --git a/ext/standard/var.c b/ext/standard/var.c index d354e0c592..6c58dcc6f6 100644 --- a/ext/standard/var.c +++ b/ext/standard/var.c @@ -378,13 +378,15 @@ static int php_object_element_export(zval **zv, int num_args, va_list args, zend level = va_arg(args, int); + php_printf("%*c", level + 1, ' '); if (hash_key->nKeyLength != 0) { - php_printf("%*c", level + 1, ' '); - zend_unmangle_property_name(hash_key->arKey, hash_key->nKeyLength-1, &class_name, &prop_name); + zend_unmangle_property_name(hash_key->arKey, hash_key->nKeyLength - 1, &class_name, &prop_name); php_printf(" '%s' => ", prop_name); - php_var_export(zv, level + 2 TSRMLS_CC); - PUTS (",\n"); + } else { + php_printf(" %ld => ", hash_key->h); } + php_var_export(zv, level + 2 TSRMLS_CC); + PUTS (",\n"); return 0; }