Bug #52940 [Asn->Csd]: call_user_func_array still allows call-time pass-by-reference

From: Date: Fri, 01 Oct 2010 11:54:05 +0000
Subject: Bug #52940 [Asn->Csd]: call_user_func_array still allows call-time pass-by-reference
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-154804@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=52940&edit=1

 ID:                 52940
 Updated by:         dmitry@php.net
 Reported by:        cataphract@php.net
 Summary:            call_user_func_array still allows call-time
                     pass-by-reference
-Status:             Assigned
+Status:             Closed
 Type:               Bug
 Package:            Scripting Engine problem
 Operating System:   Windows 7 x64; Debian Lenny x64
 PHP Version:        trunk-SVN-2010-09-28 (SVN)
 Assigned To:        dmitry
 Block user comment: N

 New Comment:

This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.




Previous Comments:
------------------------------------------------------------------------
[2010-10-01 13:53:07] dmitry@php.net

Automatic comment from SVN on behalf of dmitry
Revision: http://svn.php.net/viewvc/?view=revision&revision=303919
Log: Fixed bug #52940 (call_user_func_array still allows call-time
pass-by-reference). (cataphract@php.net)

------------------------------------------------------------------------
[2010-09-29 23:13:54] cataphract@php.net

Fixing this would also fix bug #51986.

------------------------------------------------------------------------
[2010-09-28 11:44:29] pajoye@php.net

hi Dmitry,

Can you look at this pls?

------------------------------------------------------------------------
[2010-09-28 07:11:54] cataphract@php.net

I've left the exception that was introduced for bug #50394, though I
think it should be removed for trunk.

It makes no sense to disallow this:

<?php
class A {
function __call($name, $args) {
var_dump($args);
}
}

$a = new A;
$b = 6;
$a->foobar(&$a);

yet allow this:

<?php
class A {
function __call($name, $args) {
var_dump($args);
}
}

$a = new A;
$b = 6;
call_user_func_array(array($a, 'foobar'), array(&$b));


The problem described in bug #50394 could easily be worked around by,
instead of passing by reference to __call, give the argument in an array
instead:

<?php
function foo( &$x ) { $x++; }

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

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

------------------------------------------------------------------------
[2010-09-28 06:51:01] cataphract@php.net

I ended up implemented a better strategy than separate+clear flag, as
that broke a few tests that expected the fci.params's zvals not to have
the reference flag changed.

This patch breaks only two tests that explicitly tested for the previous
behavior.

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


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    http://bugs.php.net/bug.php?id=52940


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


Thread (7 messages)

« previous php.bugs (#154804) next »