| Newsgroups |
php.bugs |
| Message-ID |
<[email protected]> |
From: as
Operating system:
PHP version: 7.0.1
Package: Variables related
Bug Type: Bug
Bug description:array_replace_recursive sometimes mutates its parameters
Description:
------------
array_replace_recursive can sometimes mutate its params if references
are nested within. This appears to be new behavior in PHP7. It also
affects PHPunit.
Test script and diff: https://3v4l.org/0sdbm
Patch attached.
Test script:
---------------
<?php
$one = [1];
$two = [42];
$arr1 = ['k' => &$one];
$arr2 = ['k' => &$two];
var_dump(current($one), current($two));
array_replace_recursive($arr1, $arr2);
var_dump(current($one), current($two));
Expected result:
----------------
int(1)
int(42)
int(1)
int(42)
Actual result:
--------------
int(1)
int(42)
int(42)
int(42)
--
Edit bug report at https://bugs.php.net/bug.php?id=71241&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=71241&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=71241&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=71241&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=71241&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=71241&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=71241&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=71241&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=71241&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=71241&r=support
Expected behavior: https://bugs.php.net/fix.php?id=71241&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=71241&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=71241&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=71241&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=71241&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=71241&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=71241&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=71241&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=71241&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=71241&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=71241&r=mysqlcfg