#24931 [Ver->Bgs]: call_user_func ignores requirement of references
| From: | iliaa@php.net | Date: | Mon, 04 Aug 2003 18:37:43 +0000 |
| Subject: | #24931 [Ver->Bgs]: call_user_func ignores requirement of references | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-45339@lists.php.net to get a copy of this message | ||
ID: 24931
Updated by: iliaa@php.net
Reported By: rehsack at liwing dot de
-Status: Verified
+Status: Bogus
Bug Type: Scripting Engine problem
Operating System: FreeBSD 5.1 i386
PHP Version: 4.3.3RC2, 5.0.0b2-dev
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
$id is modified because the original $id passed to call_user_func() is
not being passed by reference.
Previous Comments:
------------------------------------------------------------------------
[2003-08-04 03:22:31] rehsack at liwing dot de
Description:
------------
The method call_user_func ignores requirement of called
function takes it's arguments as reference. The results
in several times very ugly and hard to find bugs, eg. if
you use a template pattern combined with composite to
control child templates and want to do an action in each
child object and require to work on current data copy.
Either, if call_user_func internally is able to be called
by reference, some programs could be speed up, too (because
of the loose of expensive string copies)
This bug may related to #24631 but seems to have another
background. I can submit a more complicated example using
templates and a composite object to illustrate the problem.
Enabling call-time references in php.ini would solve this
problem by don't write a warning but I don't think it's
a good way to solve...
Reproduce code:
---------------
<?PHP
function nextId( &$id )
{
$id += 1;
}
$id = 1;
echo "before call_user_func id=$id\n";
call_user_func( "nextId", $id );
echo "after call_user_func id=$id\n";
call_user_func_array( "nextId", array( &$id ) );
echo "after call_user_func_array id=$id\n";
?>
Expected result:
----------------
before call_user_func id=1
after call_user_func id=2
after call_user_func_array id=3
Actual result:
--------------
before call_user_func id=1
after call_user_func id=1
after call_user_func_array id=2
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=24931&edit=1