diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2017-12-22 18:01:16 +0100 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2017-12-22 18:01:30 +0100 |
commit | 74e3da5c8c1e91e851ccb401b3573deef6a801f2 (patch) | |
tree | 0917679987c7d69b439095b60ea0ece69e656441 | |
parent | 3237336985dd7c262c51dbb9e8b4b3432982c04e (diff) | |
parent | ccb113c3e5964ef2d2e5b4ae3e67d61702db9bfc (diff) | |
download | php-git-74e3da5c8c1e91e851ccb401b3573deef6a801f2.tar.gz |
Merge branch 'PHP-7.1' into PHP-7.2
-rw-r--r-- | NEWS | 4 | ||||
-rw-r--r-- | ext/spl/spl_array.c | 1 | ||||
-rw-r--r-- | ext/spl/tests/bug75717.phpt | 26 |
3 files changed, 31 insertions, 0 deletions
@@ -30,6 +30,10 @@ PHP NEWS . Fixed bug #70469 (SoapClient generates E_ERROR even if exceptions=1 is used). (Anton Artamonov) +- SPL: + . Fixed bug #75717 (RecursiveArrayIterator does not traverse arrays by + reference). (Nikita) + - Zip: . Display headers (buildtime) and library (runtime) versions in phpinfo (with libzip >= 1.3.1). (Remi) diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c index a45197114a..706ce8db6d 100644 --- a/ext/spl/spl_array.c +++ b/ext/spl/spl_array.c @@ -1666,6 +1666,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 0000000000..485b9d8bc4 --- /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 |