ID:               50394
 Updated by:       j...@php.net
 Reported By:      tstarling at wikimedia dot org
-Status:           Open
+Status:           Feedback
 Bug Type:         Scripting Engine problem
 Operating System: Linux
 PHP Version:      5.3.1
 New Comment:

Regression from what version?


Previous Comments:
------------------------------------------------------------------------

[2009-12-07 01:40:18] tstarling at wikimedia dot org

Description:
------------
This is a regression in the PHP 5.3.1 release. When you call a __call()
function with a reference parameter, it is silently converted to a
value, by the time it reaches the second argument to __call().

This breaks MediaWiki and has no obvious workaround.

Reproduce code:
---------------
function foo( &$x ) {}

class Proxy {
        function __call( $name, $args ) {
                debug_zval_dump( $args );
                call_user_func_array( 'foo', $args );
        }
}

$arg = 1;
$args = array( &$arg );
$proxy = new Proxy;
call_user_func_array( array( &$proxy, 'bar' ), $args );


Expected result:
----------------
PHP 5.3.0 produces:

array(1) refcount(4){
  [0]=>
  &long(1) refcount(5)
}


Actual result:
--------------
array(1) refcount(4){
  [0]=>
  long(1) refcount(3)
}

Warning: Parameter 1 to foo() expected to be a reference, value given
in /home/tstarling/src/php/stuff/test-reference-call.php on line 8



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=50394&edit=1

Reply via email to