From: rehsack at liwing dot de Operating system: FreeBSD 5.1 i386 PHP version: 4.3.3RC2 PHP Bug Type: *General Issues Bug description: call_user_func ignores requirement of references
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 bug report at http://bugs.php.net/?id=24931&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=24931&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=24931&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=24931&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=24931&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=24931&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=24931&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=24931&r=support Expected behavior: http://bugs.php.net/fix.php?id=24931&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=24931&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=24931&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=24931&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=24931&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=24931&r=dst IIS Stability: http://bugs.php.net/fix.php?id=24931&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=24931&r=gnused