From:             abk at avatartechnology dot com
Operating system: Win 2K pro
PHP version:      4.3.4
PHP Bug Type:     Arrays related
Bug description:  unset affects "copies" of an array

Description:
------------
Unsetting an element of an array unsets that element in copies of the
array. This does not happen if you change the array or its copy in some
other way after making the copy and before doing the unset. I haven't
tested whether this affects other non-atomic types like objects, but it
wouldn't surprise me if it does.



My educated guess is there is some copy-on-write optomization that
(wrongly) does not consider "unset" to be a write.

Reproduce code:
---------------
$x = array(1,2);

$y = $x;

# uncommenting the next line "fixes" the bug:

#$x[0] = $x[0];

unset($x[0]);

print_r($y);

Expected result:
----------------
Array(0=>1,1=>2)

Actual result:
--------------
Array(1=>2)

-- 
Edit bug report at http://bugs.php.net/?id=27381&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=27381&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=27381&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=27381&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=27381&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=27381&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=27381&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=27381&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=27381&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=27381&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=27381&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=27381&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=27381&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=27381&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=27381&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=27381&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=27381&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=27381&r=float

Reply via email to