com php-src: Fixed bug #73209: NEWS ext/spl/spl_array.c e xt/spl/tests/bug73209.phpt
| From: | Nikita Popov | Date: | Fri, 22 Dec 2017 17:22:00 +0000 |
| Subject: | com php-src: Fixed bug #73209: NEWS ext/spl/spl_array.c e xt/spl/tests/bug73209.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-100673@lists.php.net to get a copy of this message | ||
Commit: f14b6f49209b360018224aec38e8ea94fcf3dbf4
Author: Nikita Popov <nikita.ppv@gmail.com> Fri, 22 Dec 2017 18:11:38 +0100
Parents: ec142f2c86c28b970aef631a5750f6a02b954089
Branches: PHP-7.1 PHP-7.2 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=f14b6f49209b360018224aec38e8ea94fcf3dbf4
Log:
Fixed bug #73209
Bugs:
https://bugs.php.net/73209
Changed paths:
M NEWS
M ext/spl/spl_array.c
A ext/spl/tests/bug73209.phpt
Diff:
diff --git a/NEWS b/NEWS
index d474e9f..478d889 100644
--- a/NEWS
+++ b/NEWS
@@ -22,6 +22,8 @@ PHP NEWS
reference). (Nikita)
. Fixed bug #75242 (RecursiveArrayIterator doesn't have constants from parent
class). (Nikita)
+ . Fixed bug #73209 (RecursiveArrayIterator does not iterate object
+ properties). (Nikita)
04 Jan 2018, PHP 7.1.13
diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c
index 105fb26...907e778 100644
--- a/ext/spl/spl_array.c
+++ b/ext/spl/spl_array.c
@@ -1642,6 +1642,10 @@ SPL_METHOD(Array, hasChildren)
RETURN_FALSE;
}
+ if (Z_TYPE_P(entry) == IS_INDIRECT) {
+ entry = Z_INDIRECT_P(entry);
+ }
+
ZVAL_DEREF(entry);
RETURN_BOOL(Z_TYPE_P(entry) == IS_ARRAY || (Z_TYPE_P(entry) == IS_OBJECT &&
(intern->ar_flags & SPL_ARRAY_CHILD_ARRAYS_ONLY) == 0));
}
@@ -1667,6 +1671,11 @@ SPL_METHOD(Array, getChildren)
return;
}
+ if (Z_TYPE_P(entry) == IS_INDIRECT) {
+ entry = Z_INDIRECT_P(entry);
+ }
+
+ ZVAL_DEREF(entry);
if (Z_TYPE_P(entry) == IS_OBJECT) {
if ((intern->ar_flags & SPL_ARRAY_CHILD_ARRAYS_ONLY) != 0) {
return;
diff --git a/ext/spl/tests/bug73209.phpt b/ext/spl/tests/bug73209.phpt
new file mode 100644
index 0000000..7383940
--- /dev/null
+++ b/ext/spl/tests/bug73209.phpt
@@ -0,0 +1,28 @@
+--TEST--
+Bug #73209: RecursiveArrayIterator does not iterate object properties
+--FILE--
+<?php
+
+class hello {
+ public $props = array();
+ function __construct() {
+ $this->props = ['hello' => 5, 'props' => ['keyme' =>
['test' => 5]]];
+ }
+}
+$data = new hello();
+
+$iterator = new RecursiveIteratorIterator(new RecursiveArrayIterator($data),
RecursiveIteratorIterator::SELF_FIRST);
+echo "Expect to see all keys in ->props here: \n";
+
+foreach($iterator as $k=>$v) {
+ echo $k . "\n";
+}
+
+?>
+--EXPECT--
+Expect to see all keys in ->props here:
+props
+hello
+props
+keyme
+test