|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2010-07-07 18:06 UTC] 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
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Dec 05 03:00:01 2025 UTC |
Actually, the reason is different. The reason of this is error is that bug reporter was using call_user_func() instead of calling the desired function directly. call_user_func() can't pass vars by reference; it simply cannot do it. So the $y gets passed by value instead, causing an error. If you need to workaround this, you should use call_user_func_array(): call_user_func_array('testfnc2', array(&$y)); // Note the & This should work alright. :)