php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72779 Passing an array by reference creates references of its values
Submitted: 2016-08-08 07:18 UTC Modified: 2016-08-08 10:18 UTC
From: lars dot schultz at toolpark dot com Assigned: cmb (profile)
Status: Not a bug Package: Variables related
PHP Version: 7.0.9 OS: Linux
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: lars dot schultz at toolpark dot com
New email:
PHP Version: OS:

 

 [2016-08-08 07:18 UTC] lars dot schultz at toolpark dot com
Description:
------------
PHP Version 7.0.3-1~dotdeb+8.1

Passing the content of an array by reference, replaces the content with a reference to it.

Getting expected behaviour in the following Versions:
PHP Version 5.3.3-7+squeeze23
PHP Version 5.4.45

Test script:
---------------
function sub(&$data){}

$data = array();
sub($data['nested']);

echo serialize(array($data,$data));

Expected result:
----------------
a:2:{i:0;a:1:{s:6:"nested";N;}i:1;a:1:{s:6:"nested";N;}}

Actual result:
--------------
a:2:{i:0;a:1:{s:6:"nested";N;}i:1;a:1:{s:6:"nested";R:3;}}

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-08-08 07:28 UTC] laruence@php.net
according to https://3v4l.org/i74nS 

this bug should be fixed already
 [2016-08-08 07:36 UTC] lars dot schultz at toolpark dot com
-Status: Open +Status: Closed -PHP Version: 7.0.9 +PHP Version: 7.0.3
 [2016-08-08 07:36 UTC] lars dot schultz at toolpark dot com
sorry, had no opportunity to test it on other versions...or rather: did not know that I had the opportunity to test it on other versions. Sorry for the bother and thanks for the hint.
 [2016-08-08 07:36 UTC] laruence@php.net
-Status: Closed +Status: Feedback -PHP Version: 7.0.3 +PHP Version: 7.0.9
 [2016-08-08 09:56 UTC] cmb@php.net
-Status: Feedback +Status: Not a bug -Assigned To: +Assigned To: cmb
 [2016-08-08 09:56 UTC] cmb@php.net
So this is not a bug. :-)
 [2016-08-08 10:01 UTC] lars dot schultz at toolpark dot com
Well...it used to be one. I couldn't find a matching Bug-Report. If it wasn't caught by a test, maybe one should be added? not sure how tests work in PHP though.
 [2016-08-08 10:18 UTC] cmb@php.net
It appears to me that the commit that fixed this issue was
<http://git.php.net/?p=php-src.git;a=commit;h=7989db9>. There is
alread a PHPT[1] attached, so we do have a regression test
already.

[1] <http://qa.php.net/write-test.php>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 11:01:30 2024 UTC