Bug #72622 [NEW]: array_walk + array_replace_recursive create references from nothing

From: Date: Tue, 19 Jul 2016 15:49:13 +0000
Subject: Bug #72622 [NEW]: array_walk + array_replace_recursive create references from nothing
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-202421@lists.php.net to get a copy of this message
From: srspam+phpnet at icloud dot com Operating system: Linux PHP version: 7.0.8 Package: Variables related Bug Type: Bug Bug description:array_walk + array_replace_recursive create references from nothing 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 bug report at https://bugs.php.net/bug.php?id=72622&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=72622&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=72622&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=72622&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=72622&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=72622&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=72622&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=72622&r=needscript Try newer version: https://bugs.php.net/fix.php?id=72622&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=72622&r=support Expected behavior: https://bugs.php.net/fix.php?id=72622&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=72622&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=72622&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=72622&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=72622&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=72622&r=dst IIS Stability: https://bugs.php.net/fix.php?id=72622&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=72622&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=72622&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=72622&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=72622&r=mysqlcfg

« previous php.bugs (#202421) next »