[wp-trac] [WordPress Trac] #20163: Call-time pass-by-reference has been removed in PHP (Fatal error in 5.4) or deprecated (Warning in 5.3)
WordPress Trac
wp-trac at lists.automattic.com
Wed Mar 7 23:38:53 UTC 2012
#20163: Call-time pass-by-reference has been removed in PHP (Fatal error in 5.4) or
deprecated (Warning in 5.3)
------------------------------+--------------------------
Reporter: emiluzelac | Owner: koopersmith
Type: defect (bug) | Status: reviewing
Priority: normal | Milestone: 3.4
Component: Warnings/Notices | Version: 3.4
Severity: normal | Resolution:
Keywords: has-patch |
------------------------------+--------------------------
Comment (by kurtpayne):
duck_ and ocean90, thanks for the code review. I took a second look based
on your feedback and you're right, [[attachment:20163.patch]] was too
aggressive and doesn't belong in this ticket. I don't think any further
patches are necessary for this specific problem.
For posterity's sake, I'm documenting my findings below. I hope it helps
somebody!
{{{
#!php
<?php
function test($s) {echo $s;}
function test2($x) {test(array_pop($x));}
$x = "Hello World\n";
test($x); // Works
test2(array(&$x)); // Works
call_user_func('test', $x); // Works
call_user_func_array('test', array($x)); // Works
call_user_func_array('test', array(&$x)); // Works
test(&$x); // <---------- Deprecated, doesn't work
call_user_func('test', &$x); // <------ Deprecated, see note below
}}}
This note is on the PHP documentation page for
[http://php.net/manual/en/function.call-user-func-array.php
call_user_func_array]
> Referenced variables in param_arr are passed to the function by
reference, regardless of whether the function expects the respective
parameter to be passed by reference. This form of call-time pass by
reference does not emit a deprecation notice, but it is nonetheless
deprecated, and will most likely be removed in the next version of PHP ...
This note is on the PHP documentation page for
[http://php.net/manual/en/function.call-user-func.php call_user_func]
> Note that the parameters for call_user_func() are not passed by
reference.
I scanned trunk with the following command (if someone wants to replicate
my work). I went through the results and did not find any code that
required changes.
{{{
find . -type f -name "*.php" -exec egrep -Hri '[&][$]' {} \; | egrep -v
"function\s*[&]?[a-zA-Z0-9_]+\s*\(" | egrep -v "[*]\s*@(param|return)"|
egrep -v "=[>]?\s*[&][$]" | grep -v "\s*as\s*[&][$]"
}}}
+1 for fixed.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/20163#comment:17>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list