#24630 [NEW]: extract with EXTR_REFS makes weird references

From: Date: Sun, 13 Jul 2003 01:47:59 +0000
Subject: #24630 [NEW]: extract with EXTR_REFS makes weird references
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-43838@lists.php.net to get a copy of this message
From: tater at potatoe dot com Operating system: OS X 10.2 PHP version: 4.3.3RC1 PHP Bug Type: Scripting Engine problem Bug description: extract with EXTR_REFS makes weird references Description: ------------ If you create an array by assigning its elements the value of a scalar variable (or, in PHP5, by using array_combine() with an array of keys and an array built with array_fill() or array_pad()), then extract(array, EXTR_REFS) will make that scalar into a reference, as well as making all the array elements references to the same... location? I don't know, they all end up pointing to the same thing, so that changing any one of them changes all of them. This tests the same on the current PHP4 release and the latest CVS PHP5 code. Reproduce code: --------------- <?php function trap() { $tick = 0; $x = array('x1'=>$tick, 'x2'=>$tick, 'x3'=>0, 'x4'=>0); $y = array('y1'=>$tick, 'y2'=>$tick, 'y3'=>0, 'y4'=>0); var_dump(get_defined_vars()); foreach ($x as $k => $v) $$k =& $x[$k]; extract($y, EXTR_REFS); var_dump(get_defined_vars()); $x1 = 1; $y1 = 2; $y3 = 4; var_dump(get_defined_vars()); $tick = 5; var_dump(get_defined_vars()); } trap(); ?> Expected result: ---------------- Changing $y1 should only change it and y['y1']. Changing $tick should only change $tick. Actual result: -------------- Changing $y1 or $tick changes the other as well. -- Edit bug report at http://bugs.php.net/?id=24630&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=24630&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=24630&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=24630&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=24630&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=24630&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=24630&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=24630&r=support Expected behavior: http://bugs.php.net/fix.php?id=24630&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=24630&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=24630&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=24630&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=24630&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=24630&r=dst IIS Stability: http://bugs.php.net/fix.php?id=24630&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=24630&r=gnused

« previous php.bugs (#43838) next »