]> granicus.if.org Git - php/commitdiff
- MFH: Fixed bug #47027 (var_export doesn't show numeric indices on ArrayObject).
authorDerick Rethans <derick@php.net>
Wed, 7 Jan 2009 14:36:49 +0000 (14:36 +0000)
committerDerick Rethans <derick@php.net>
Wed, 7 Jan 2009 14:36:49 +0000 (14:36 +0000)
NEWS
ext/standard/tests/general_functions/bug47027.phpt [new file with mode: 0644]
ext/standard/var.c

diff --git a/NEWS b/NEWS
index 01ef2d7a180c1f7a5c86ea4e2acb9c1a5f62f85f..a1b51b027899f025b054c2f78b10eff71d5c2e42 100644 (file)
--- 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 (file)
index 0000000..e4f5aae
--- /dev/null
@@ -0,0 +1,12 @@
+--TEST--
+Bug #47027 (var_export doesn't show numeric indices on ArrayObject)
+--FILE--
+<?php
+$ao = new ArrayObject(array (2 => "foo", "bar" => "baz"));
+var_export ($ao);
+?>
+--EXPECT--
+ArrayObject::__set_state(array(
+   2 => 'foo',
+   'bar' => 'baz',
+))
index d354e0c592df168c41f46ec0ee6fc4602882d09f..6c58dcc6f634c063fe10f14e2690189dd0b16882 100644 (file)
@@ -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;
 }