Bug #72622 [Opn->Csd]: array_walk + array_replace_recursive create references from nothing
| From: | laruence@php.net | Date: | Wed, 20 Jul 2016 08:13:37 +0000 |
| Subject: | Bug #72622 [Opn->Csd]: array_walk + array_replace_recursive create references from nothing | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-202432@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=72622&edit=1
ID: 72622
Updated by: laruence@php.net
Reported by: srspam+phpnet at icloud dot com
Summary: array_walk + array_replace_recursive create
references from nothing
-Status: Open
+Status: Closed
Type: Bug
Package: Variables related
Operating System: Linux
PHP Version: 7.0.8
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of laruence@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=3c3b8c8365dc9ac7d62034c9eecbabb4800b7353
Log: Fixed bug #72622 (array_walk + array_replace_recursive create references from nothing)
Previous Comments:
------------------------------------------------------------------------
[2016-07-19 15:49:10] srspam+phpnet at icloud dot com
Description:
------------
When an array has been passed to array_walk, with a callback that accepts the first value by
reference, and the array is then passed as an argument to array_replace_recursive, an apparent
reference is created for each element of the array, which then triggers bug #71241.
The test script attached gives the correct output under php 5.6 and 5.5, but gives the wrong result
under 7.0.8
Test script:
---------------
<?php
function walk (array $arr) {
array_walk($arr, function (&$val, $name) {
});
return $arr;
}
$arr3 = ['foo' => 'foo'];
$arr4 = walk(['foo' => 'bar']);
$arr5 = array_replace_recursive($arr3, $arr4);
$arr5['foo'] = 'baz';
var_dump($arr3, $arr4, $arr5);
Expected result:
----------------
array(1) {
'foo' =>
string(3) "foo"
}
array(1) {
'foo' =>
string(3) "bar"
}
array(1) {
'foo' =>
string(3) "baz"
}
Actual result:
--------------
array(1) {
["foo"]=>
string(3) "foo"
}
array(1) {
["foo"]=>
&string(3) "baz"
}
array(1) {
["foo"]=>
&string(3) "baz"
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=72622&edit=1