summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDerick Rethans <derick@php.net>2009-01-07 14:36:49 +0000
committerDerick Rethans <derick@php.net>2009-01-07 14:36:49 +0000
commit3c15c0089182c27d2d823bc12a9474a795dbc363 (patch)
tree2a192c35f064b71cd66c64539afcdeadcabf4faa
parent3247a9c40b4891a0a6fca9d0ab12a1f6e479e649 (diff)
downloadphp-git-3c15c0089182c27d2d823bc12a9474a795dbc363.tar.gz
- MFH: Fixed bug #47027 (var_export doesn't show numeric indices on ArrayObject).
-rw-r--r--NEWS2
-rw-r--r--ext/standard/tests/general_functions/bug47027.phpt12
-rw-r--r--ext/standard/var.c10
3 files changed, 20 insertions, 4 deletions
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--
+<?php
+$ao = new ArrayObject(array (2 => "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;
}