From:             a dot yamanoi at gmail dot com
Operating system: 
PHP version:      5.2.3
PHP Bug Type:     SPL related
Bug description:  SPL ArrayObject does not use "copy-on-write"

Description:
------------
When ArrayObject::offsetSet() method stores a new value into an array,
I expect ArrayObject to change only the array which is given as a
constructor parameter.

However, if the array is copied from another array and unchanged,
ArrayObject will also change the another array.

I thought it was a "copy-on-write" problem.

thank you for any help
Please excuse my English, it isn't very good.

Reproduce code:
---------------
$base = array('key' => 'old value');

$copy = $base;
$ao = new ArrayObject($copy);
$ao['key'] = 'new value';

echo '$base["key"] = ', $base['key'], "\n";
echo '$copy["key"] = ', $copy['key'], "\n";
echo '$ao["key"] = ', $ao['key'], "\n";

Expected result:
----------------
$base["key"] = old value
$copy["key"] = new value
$ao["key"] = new value

Actual result:
--------------
$base["key"] = new value
$copy["key"] = new value
$ao["key"] = new value

-- 
Edit bug report at http://bugs.php.net/?id=42065&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=42065&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=42065&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=42065&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=42065&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=42065&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=42065&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=42065&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=42065&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=42065&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=42065&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=42065&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=42065&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=42065&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=42065&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=42065&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=42065&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=42065&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=42065&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=42065&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=42065&r=mysqlcfg

Reply via email to