Bug #52277 [Opn->Bgs]: fatal error with call_user_func and function with by-reference arguments
| From: | rasmus@php.net | Date: | Wed, 07 Jul 2010 16:14:50 +0000 |
| Subject: | Bug #52277 [Opn->Bgs]: fatal error with call_user_func and function with by-reference arguments | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-152187@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=52277&edit=1
ID: 52277
Updated by: rasmus@php.net
Reported by: abautu at gmail dot com
Summary: fatal error with call_user_func and function with
by-reference arguments
-Status: Open
+Status: Bogus
Type: Bug
Package: Scripting Engine problem
Operating System: Ubuntu 10.04
PHP Version: 5.3.2
New Comment:
Passing a static string into a function that takes the parameter by
reference
makes no sense. If that function were to modify the passed parameter,
there would
be no place to store those changes, so this should fail. You also get a
nice fat
warning that looks like this:
Warning: Parameter 1 to testfnc2() expected to be a reference, value
given
So make sure you have your error_reporting() level set high enough.
Previous Comments:
------------------------------------------------------------------------
[2010-07-07 18:06:15] abautu at gmail dot com
Description:
------------
I have a Drupal site. It worked ok until I upgraded php to 5.3.2. It
simply fails, nothing is written to the error log or on the screen.
I tracked down the problem to the following point:
* in some file, there is this call:
return call_user_func($hook_function, $variables, $suggestions);
where $hook_function is _phptemplate_page
* _phptemplate_page function is defined as:
function _phptemplate_page(&$variables, &$suggestions) {
....
}
If I remove the & before variables, the site works. I know the
by-reference variable behavior changed in 5.3.2 from 5.2, but in this
case, the actual parameters are still 2 variables (not constants).
Cheers,
Andrei
Test script:
---------------
<?php
function testfnc1($x) {
echo "testfnc1: $x ";
}
function testfnc2(&$x) {
echo "testfnc2: $x ";
}
$y = 'works';
call_user_func('testfnc1', $y);
call_user_func('testfnc2', $y);
Expected result:
----------------
testfnc1: works testfnc2: works
Actual result:
--------------
testfnc1: works
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=52277&edit=1