From: sir dot mordred dot service at gmail dot com
Operating system: Windows XP, apache 2.0
PHP version: 4.4.6
PHP Bug Type: Scripting Engine problem
Bug description: Pass by reference and object assignment problem
Description:
------------
If a parameter passed by reference to a function is assigned a new object
with the =& operator, after the function call the variable passed to the
function will not contain the object, but its previous value (or null).
Assignment with = works fine.
Reproduce code:
---------------
<pre><?php
class A {}
function Foo(&$param)
{
$param =& new A();
}
function Bar(&$param)
{
$param = new A();
}
echo phpversion()."\n";
$p = 1;
Foo($p);
var_dump($p);
$q = 1;
Bar($q);
var_dump($q);
?>
Expected result:
----------------
4.4.6
object(a)(0) {
}
object(a)(0) {
}
Actual result:
--------------
4.4.6
int(1)
object(a)(0) {
}
--
Edit bug report at http://bugs.php.net/?id=40981&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=40981&r=trysnapshot44
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=40981&r=trysnapshot52
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=40981&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=40981&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=40981&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=40981&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=40981&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=40981&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=40981&r=support
Expected behavior: http://bugs.php.net/fix.php?id=40981&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=40981&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=40981&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=40981&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=40981&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=40981&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=40981&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=40981&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=40981&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=40981&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=40981&r=mysqlcfg