#39202 [NEW]: Temporary tables with references dereference

From: Date: Thu, 19 Oct 2006 20:56:01 +0000
Subject: #39202 [NEW]: Temporary tables with references dereference
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-103755@lists.php.net to get a copy of this message
From: cpriest at warpmail dot net Operating system: Apache 2.0.55 PHP version: 5.1.6 PHP Bug Type: Arrays related Bug description: Temporary tables with references dereference Description: ------------ References in temporary tables de-reference their references upon crossing function boundaries Reproduce code: --------------- <?php class myClassA { public $Name = ''; function __construct($Name) { $this->Name = $Name; } } global $tblData; $tblData = array( 'Test' => new myClassA('Object 1'), 'Test2' => new myClassA('Object 2'), ); function getReferenced() { global $tblData; $tblData2 = array( 'Test' => &$tblData['Test'], 'Test2' => &$tblData['Test2'], ); return $tblData2; } echo '<plaintext>'; print_r($tblData); $tblData2 = getReferenced(); $tblData2['Test']->Name = 'Object 3'; print_r($tblData2); ?> Expected result: ---------------- I expect there to be only two objects at the end of the call, one with a Name of 'Object 3' and one with a Name of 'Object 2' Actual result: -------------- Three objects exist, 'Object 1', 'Object 2', and 'Object 3' -- Edit bug report at http://bugs.php.net/?id=39202&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=39202&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=39202&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=39202&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=39202&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=39202&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=39202&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=39202&r=needscript Try newer version: http://bugs.php.net/fix.php?id=39202&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=39202&r=support Expected behavior: http://bugs.php.net/fix.php?id=39202&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=39202&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=39202&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=39202&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=39202&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=39202&r=dst IIS Stability: http://bugs.php.net/fix.php?id=39202&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=39202&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=39202&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=39202&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=39202&r=mysqlcfg

« previous php.bugs (#103755) next »