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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: tony2001@php.net
New email:
PHP Version: OS:

 

 [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-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 21:01:30 2024 UTC