#25690 [Opn->Bgs]: call_user_func_array disrespect returned references
| From: | sniper@php.net | Date: | Tue, 30 Sep 2003 00:58:47 +0000 |
| Subject: | #25690 [Opn->Bgs]: call_user_func_array disrespect returned references | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-48283@lists.php.net to get a copy of this message | ||
ID: 25690
Updated by: sniper@php.net
Reported By: ask-me at ask-me dot ru
-Status: Open
+Status: Bogus
Bug Type: Scripting Engine problem
Operating System: All
PHP Version: 4.3.3
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
..
Previous Comments:
------------------------------------------------------------------------
[2003-09-29 09:29:07] ask-me at ask-me dot ru
Description:
------------
Unfortunatly even in version 4.3.3 there was an bug with
"call_user_func_array" function.
call_user_func and call_user_func do respect functions that return
references. That is, function foo that returns a references to an
object, does not return a reference to an object when foo is called
via
call_user_func. Instead, foo called via call_user_func returns a
"copy"
of the object. (I'm not sure "copy" is the right word.) See the code
example for a concise example of the problem.
Reproduce code:
---------------
function &testfunction()
{
global $testglobal;
return ($testglobal=1);
}
$testglobal_link=&call_user_func_array("testfunction",array('testparam-1','testparam-2'));
// $testglobal_link must be link to $testglobal at this stage
print $testglobal_link;
// trying to assign new value to $testglobal thru link
$testglobal_link=2;
// in theory we will get "2" as result
print $testglobal;
// but unfortunatly we will have "1" as result
print $testglobal_link;
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=25690&edit=1