php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72369 array_merge() produces references in PHP7
Submitted: 2016-06-09 11:34 UTC Modified: 2016-06-09 11:35 UTC
From: tony2001@php.net Assigned: dmitry (profile)
Status: Closed Package: Arrays related
PHP Version: 7.0.8RC1 OS: *
Private report: No CVE-ID: None
 [2016-06-09 11:34 UTC] tony2001@php.net
Description:
------------
array_merge() changed behavior in PHP7, the reproduce script below produces references, which it didn't do in PHP5.

Test script:
---------------
<?php
$x = 'xxx';
$d = ['test' => &$x];
unset($x);
$a = ['test' => 'yyy'];
$a = array_merge($a, $d);
debug_zval_dump($a);
?>

Expected result:
----------------
array(1) refcount(2){
  ["test"]=>
  string(3) "xxx" refcount(2)
}


Actual result:
--------------
array(1) refcount(2){
  ["test"]=>
  &string(3) "xxx" refcount(1)
}


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-06-09 11:35 UTC] tony2001@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: dmitry
 [2016-06-09 12:09 UTC] dmitry@php.net
Automatic comment on behalf of dmitry@zend.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=bfcf32237e32b46cba7ce2f9bcd36482978f8dd8
Log: Fixed bug #72369 (array_merge() produces references in PHP7)
 [2016-06-09 12:09 UTC] dmitry@php.net
-Status: Assigned +Status: Closed
 [2016-06-22 05:58 UTC] krakjoe@php.net
Automatic comment on behalf of dmitry@zend.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=bfcf32237e32b46cba7ce2f9bcd36482978f8dd8
Log: Fixed bug #72369 (array_merge() produces references in PHP7)
 [2016-07-20 11:30 UTC] davey@php.net
Automatic comment on behalf of dmitry@zend.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=bfcf32237e32b46cba7ce2f9bcd36482978f8dd8
Log: Fixed bug #72369 (array_merge() produces references in PHP7)
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Tue Mar 09 08:01:24 2021 UTC