From:             eric dot daspet at survol dot net
Operating system: MS Windows XP
PHP version:      5.1.4
PHP Bug Type:     SPL related
Bug description:  unseting an index on ArrayObject may modify the original array

Description:
------------
Deleting an index in ArrayObjet also delete it from the original array *if
and only if* ArrayObject was not modified.

This may introduce bugs (unexpected deletion in the original array).



Note: if modification of the original array is wanted behaviour, then we
have the opposite bugs :
- documentation does not says that the array in ArrayObject constructor is
passed as reference
- I we modify the value of some entry in ArrayObject, the the relation
between ArrayObject and the original array is lost 

Reproduce code:
---------------
<?php

$array = array('foo' => 'bar') ;
$object = new ArrayObject( $array ) ;


// uncomment this for opposite behaviour 
// and loose the reference between $object and $array
// $objet['foo'] = 'hello' ;


unset($objet['foo']);
var_dump( $array ) ;

Expected result:
----------------
array(1) { ["foo"]=>  string(3) "bar" }

Actual result:
--------------
array(0) {  }

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

Reply via email to