Edit report at https://bugs.php.net/bug.php?id=50394&edit=1
ID: 50394
Comment by: bgardner at noggin dot com dot au
Reported by: tstarling at wikimedia dot org
Summary: Reference argument converted to value in __call
Status: Closed
Type: Bug
Package: Scripting Engine problem
Operating System: Linux
PHP Version: 5.3.1
Assigned To: pajoye
Block user comment: N
Private report: N
New Comment:
And a test case that shows the weirdness. Run against PHP 5.3.3
<?php
function foo($a,&$b){
print $a . ' ' . $b . "\n";
}
function fails(){
$args = func_get_args();
call_user_func_array('foo',$args);
}
function works(){
$args = func_get_args();
$newargs = array();
foreach (array_keys($args) as $k){
$newargs[$k] = &$args[$k];
}
//Notice here that I do not pass in $newargs, but $args
call_user_func_array('foo',$args);
}
works('Hello','World');
fails('Hello','World');
?>
Previous Comments:
------------------------------------------------------------------------
[2013-06-12 11:54:24] merzikain at yahoo dot com
Still a bug with 5.4.16 as well.
------------------------------------------------------------------------
[2013-05-08 14:55:35] dessander at gmail dot com
Still active bug.
My PHP Version:
PHP 5.4.14 (cli) (built: Apr 11 2013 19:13:00)
Code to reproduce:
<?php
class TestForCall
{
public static function myFunc($test, &$reference_var)
{
var_dump($test);
$reference_var = 'changed';
}
}
class Test
{
public function __call($name, $arguments)
{
return call_user_func_array(
array(
'TestForCall',
'myFunc'
),
$arguments
);
}
}
(new Test())
->notExistsFunction('test', $reference_var)
;
var_dump($reference_var);
Output:
PHP Warning: Parameter 2 to TestForCall::myFunc() expected to be a reference, value given in
/www/godudu.local/test.php on line 22
Warning: Parameter 2 to TestForCall::myFunc() expected to be a reference, value given in
/www/godudu.local/test.php on line 22
NULL
------------------------------------------------------------------------
[2010-10-22 07:58:58] john dot GTD at yahoo dot com
What are the exact steps to reproduce the problem?
I'm running MediaWiki on UniformServer with PHP 5.3.3 and didn't have any problems
yet.
------------------------------------------------------------------------
[2010-10-11 04:18:58] master33rd at yahoo dot com
I find it disturbing that the bug has been declared fixed, when it hasn't.
Starting Mediawiki with Xampp (even with the new beta of XAMPP)...the same error occurs. "PHP
5.3.1 is not compatible with MediaWiki due to a bug involving reference parameters to __call.
Upgrade to PHP 5.3.2 or higher, or downgrade to PHP 5.3.0 to fix this. ABORTING (see http://bugs.php.net/bug.php?id=50394 for
details)" Upgrading to PhP 5.3.3 doesn't fix the problem.
Let's stop passing the buck and fix this.
------------------------------------------------------------------------
[2010-09-21 11:49:39] hugoniks at hotmail dot com
wtff
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=50394
--
Edit this bug report at https://bugs.php.net/bug.php?id=50394&edit=1