Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Fix recursion checks in array_*_recursive
Summary: array_merge_recursive and array_replace_recursive do recursion checks, but use the fact that normal arrays can't contain cycles except through references to avoid most of the checking. Unfortunately the $GLOBALS array is special, and /can/ contain cycles without references, and ProxyArrays could potentially do the same (via an as-yet unimplemented extension). Reviewed By: mxw Differential Revision: D3622612 fbshipit-source-id: ed90b747096a05919a80c4793e2a2b7c57584d56
- Loading branch information
mwilliams@fb.com
authored and
Hhvm Bot
committed
Aug 1, 2016
1 parent
f7ae929
commit 05e706d
Showing
3 changed files
with
58 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| <?php | ||
|
|
||
| function test($g) { | ||
| $GLOBALS['g'] = $GLOBALS; | ||
|
|
||
| array_replace_recursive($GLOBALS, $g); | ||
|
|
||
| $GLOBALS['g'] = $GLOBALS; | ||
| array_merge_recursive($GLOBALS, $g); | ||
| } | ||
|
|
||
| function main() { | ||
| $a = array(); | ||
| $a['g'] = &$a; | ||
|
|
||
| test($a); | ||
| test($GLOBALS); | ||
| } | ||
|
|
||
| main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
|
|
||
| Warning: array_replace_recursive(): recursion detected in %s/test/slow/array_functions/self_recursive.php on line 6 | ||
|
|
||
| Warning: array_merge_recursive(): recursion detected in %s/test/slow/array_functions/self_recursive.php on line 9 | ||
|
|
||
| Warning: array_merge_recursive(): recursion detected in %s/test/slow/array_functions/self_recursive.php on line 9 | ||
|
|
||
| Warning: array_merge_recursive(): recursion detected in %s/test/slow/array_functions/self_recursive.php on line 9 | ||
|
|
||
| Warning: array_merge_recursive(): recursion detected in %s/test/slow/array_functions/self_recursive.php on line 9 | ||
|
|
||
| Warning: array_merge_recursive(): recursion detected in %s/test/slow/array_functions/self_recursive.php on line 9 |