#49500 [Bgs]: call_user_func object parameter is not passed as reference
| From: | casper at procurios dot nl | Date: | Wed, 09 Sep 2009 07:40:01 +0000 |
| Subject: | #49500 [Bgs]: call_user_func object parameter is not passed as reference | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-142129@lists.php.net to get a copy of this message | ||
ID: 49500
User updated by: casper at procurios dot nl
Reported By: casper at procurios dot nl
Status: Bogus
Bug Type: Scripting Engine problem
Operating System: Linux
PHP Version: 5.3.0
New Comment:
Jani, could you tell me what bug number this is related to? I have been
searching for it before I posted this one, searched again now. I found
duplicate bug #44626 but that one is marked bogus as well.
Two other bugs #43568 & #47402 deal with call_user_func too, but seem
unrelated.
Previous Comments:
------------------------------------------------------------------------
[2009-09-08 17:33:10] jani@php.net
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same.
Thank you for your interest in PHP.
------------------------------------------------------------------------
[2009-09-08 15:28:48] casper at procurios dot nl
My workaround code has a similar issue:
function workaroundforbug49500_call_user_func()
{
$params = func_get_args();
$func = array_shift($params);
return call_user_func_array($func, $params);
}
Casts: 'PHP warning Parameter 1 to myFunction() expected to be a
reference, value given' too.
func_get_args() seems affected too.
------------------------------------------------------------------------
[2009-09-08 15:03:02] casper at procurios dot nl
Description:
------------
When call_user_func is called with an object as it's second parameter,
it's not passed as reference. Instead the PHP warning 'Parameter 1 to
myFunction() expected to be a reference, value given' is cast.
myFunction() is not called at all.
This is a major compatibility break from 5.2.
Reproduce code:
---------------
class MyClass {
var $someVar = 'test';
}
function myFunction(&$Object) {
echo $Object->someVar . "\n";
}
$Object = new MyClass();
myFunction($Object);
call_user_func('myFunction', $Object);
Expected result:
----------------
test
test
Actual result:
--------------
test
PHP warning Parameter 1 to myFunction() expected to be a reference,
value given
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=49500&edit=1