|  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
 [2016-08-08 07:18 UTC] lars dot schultz at toolpark dot com
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();

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

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-08-08 07:28 UTC]
according to 

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]
-Status: Closed +Status: Feedback -PHP Version: 7.0.3 +PHP Version: 7.0.9
 [2016-08-08 09:56 UTC]
-Status: Feedback +Status: Not a bug -Assigned To: +Assigned To: cmb
 [2016-08-08 09:56 UTC]
So this is not a bug. :-)
 [2016-08-08 10:01 UTC] lars dot schultz at toolpark dot com 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]
It appears to me that the commit that fixed this issue was
<;a=commit;h=7989db9>. There is
alread a PHPT[1] attached, so we do have a regression test

[1] <>
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 12 21:01:30 2024 UTC