From:             ask-me at ask-me dot ru
Operating system: All
PHP version:      4.3.3
PHP Bug Type:     Scripting Engine problem
Bug description:  call_user_func_array disrespect returned references

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 bug report at http://bugs.php.net/?id=25690&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=25690&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=25690&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=25690&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=25690&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=25690&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=25690&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=25690&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=25690&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=25690&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=25690&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=25690&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=25690&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=25690&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=25690&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=25690&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=25690&r=float

Reply via email to