#42065 [Opn->Fbk]: SPL ArrayObject does not use "copy-on-write"
| From: | jani@php.net | Date: | Sun, 22 Jul 2007 15:34:49 +0000 |
| Subject: | #42065 [Opn->Fbk]: SPL ArrayObject does not use "copy-on-write" | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-115303@lists.php.net to get a copy of this message | ||
ID: 42065
Updated by: jani@php.net
Reported By: a dot yamanoi at gmail dot com
-Status: Open
+Status: Feedback
Bug Type: SPL related
PHP Version: 5.2.3
New Comment:
Please try using this CVS snapshot:
http://snaps.php.net/php5.2-latest.tar.gz
For Windows (zip):
http://snaps.php.net/win32/php5.2-win32-latest.zip
For Windows (installer):
http://snaps.php.net/win32/php5.2-win32-installer-latest.msi
This might have already been fixed..
Previous Comments:
------------------------------------------------------------------------
[2007-07-22 11:05:27] a dot yamanoi at gmail dot com
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 this bug report at http://bugs.php.net/?id=42065&edit=1