diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2017-12-22 18:01:53 +0100 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2017-12-22 18:01:53 +0100 |
commit | 9fe0eb8c48c5579b3670574511a42d1f2530442f (patch) | |
tree | e0128def583144cc2ddf7c6a122285f8e37e84f2 /ext/spl | |
parent | 8bcedb6cd7333f3ed8810dffffb04af423fccd4d (diff) | |
parent | 74e3da5c8c1e91e851ccb401b3573deef6a801f2 (diff) | |
download | php-git-9fe0eb8c48c5579b3670574511a42d1f2530442f.tar.gz |
Merge branch 'PHP-7.2'
Diffstat (limited to 'ext/spl')
-rw-r--r-- | ext/spl/spl_array.c | 1 | ||||
-rw-r--r-- | ext/spl/tests/bug75717.phpt | 26 |
2 files changed, 27 insertions, 0 deletions
diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c index 5da552ce0e..d6cb4b6fb7 100644 --- a/ext/spl/spl_array.c +++ b/ext/spl/spl_array.c @@ -1662,6 +1662,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 |