Edit report at https://bugs.php.net/bug.php?id=50394&edit=1
ID: 50394
Comment by: merzikain at yahoo dot com
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:
Still a bug with 5.4.16 as well.
Previous Comments:
------------------------------------------------------------------------
[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
------------------------------------------------------------------------
[2010-09-20 05:14:07] tstarling at wikimedia dot org
heis: yes, the behaviour changed in 5.3.0. I'm not saying it was a good idea,
I'm just saying you should complain on some other bug report, preferably one
that I'm not CC'ed on.
The correct way to pass reference arguments to functions via
call_user_func_array() hasn't changed, we've been doing it this way since PHP
4. It's just that the impact of doing it the wrong way has changed. Previously,
the argument was silently converted to a value. Now, a warning is shown and the
function isn't called.
------------------------------------------------------------------------
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