com php-src: Fixed bug #75717: NEWS ext/spl/spl_array.c e xt/spl/tests/bug75717.phpt
| From: | Nikita Popov | Date: | Fri, 22 Dec 2017 17:01:03 +0000 |
| Subject: | com php-src: Fixed bug #75717: NEWS ext/spl/spl_array.c e xt/spl/tests/bug75717.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-100667@lists.php.net to get a copy of this message | ||
Commit: ccb113c3e5964ef2d2e5b4ae3e67d61702db9bfc
Author: Nikita Popov <nikita.ppv@gmail.com> Fri, 22 Dec 2017 18:00:17 +0100
Parents: 024637378827ff03ccfb6b903c9d9b968d30af8d
Branches: PHP-7.1 PHP-7.2 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=ccb113c3e5964ef2d2e5b4ae3e67d61702db9bfc
Log:
Fixed bug #75717
Bugs:
https://bugs.php.net/75717
Changed paths:
M NEWS
M ext/spl/spl_array.c
A ext/spl/tests/bug75717.phpt
Diff:
diff --git a/NEWS b/NEWS
index 2483bd6..c7d75f1 100644
--- a/NEWS
+++ b/NEWS
@@ -15,7 +15,11 @@ PHP NEWS
- SOAP:
. Fixed bug #70469 (SoapClient generates E_ERROR even if exceptions=1 is
-used). (Anton Artamonov)
+ used). (Anton Artamonov)
+
+- SPL:
+ . Fixed bug #75717 (RecursiveArrayIterator does not traverse arrays by
+ reference). (Nikita)
04 Jan 2018, PHP 7.1.13
diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c
index 81bbe48..1be55d7 100644
--- a/ext/spl/spl_array.c
+++ b/ext/spl/spl_array.c
@@ -1642,6 +1642,7 @@ SPL_METHOD(Array, hasChildren)
RETURN_FALSE;
}
+ 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));
}
/* }}} */
diff --git a/ext/spl/tests/bug75717.phpt b/ext/spl/tests/bug75717.phpt
new file mode 100644
index 0000000..485b9d8
--- /dev/null
+++ b/ext/spl/tests/bug75717.phpt
@@ -0,0 +1,26 @@
+--TEST--
+Bug #75717: RecursiveArrayIterator does not traverse arrays by reference
+--FILE--
+<?php
+
+function flatten(array $nestedArraysAndStrings){
+ $flat=[];
+ $iter = new RecursiveIteratorIterator(
+ new RecursiveArrayIterator($nestedArraysAndStrings));
+ foreach($iter as $leaf){ $flat[] = $leaf; }
+ return join(NULL, $flat);
+}
+
+$noRefs = [[[['some']]],[' nested '],"items"];
+
+$withRefs = []+$noRefs;
+$wat = $noRefs[0];
+$withRefs[0] = &$wat;
+
+echo flatten($noRefs), "\n";
+echo flatten($withRefs), "\n";
+
+?>
+--EXPECT--
+some nested items
+some nested items