ID: 42065 User updated by: a dot yamanoi at gmail dot com Reported By: a dot yamanoi at gmail dot com -Status: Feedback +Status: Closed Bug Type: SPL related -Operating System: +Operating System: * PHP Version: 5.2.3 New Comment:
Thank you very much for your prompt reply. It is fixed in the latest snapshot. > php -v PHP 5.2.4-dev (cli) (built: Jul 23 2007 00:04:07) Expected result: ---------------- $base["key"] = old value $copy["key"] = old value <--- (In my first entry, this line was wrong.) $ao["key"] = new value I can get the expected result! Thank you very much for your time. Previous Comments: ------------------------------------------------------------------------ [2007-07-22 15:34:48] [EMAIL PROTECTED] 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.. ------------------------------------------------------------------------ [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
