diff options
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 |