From:             
Operating system: openSUSE 11.4/Debian 5
PHP version:      Irrelevant
Package:          SPL related
Bug Type:         Bug
Bug description:ArrayIterator::offsetUnset(); does not work correctly

Description:
------------
ArrayIterator always skips the second element in the array when calling 
offsetUnset(); on it while looping through.

Using the key from iterator and unsetting in the actual ArrayObject works
as 
expected.

Running php 5.3.5 on openSUSE 11.4
Replicated same bug on Debian 5 running PHP 5.2.6-1+lenny9.

php5 is installed as binary on both systems, SPL is builtin package.


Test script:
---------------
<?php

// Create a array range from 0 to 9
$a = new ArrayObject( range( 0,9 ) );
$b = new ArrayIterator( $a );
 
for ( $b->rewind(); $b->valid(); $b->next() )
{
    echo "#{$b->current()} - \r\n";
    $b->offsetUnset( $b->key() );
}
?>

Expected result:
----------------
Expected a list of from 0 to 9 echoed out.

Actual result:
--------------
Lists out 0 and then 2-9 leaving index 1 untouched in the original
ArrayObject.


-- 
Edit bug report at https://bugs.php.net/bug.php?id=55157&edit=1
-- 
Try a snapshot (PHP 5.2):            
https://bugs.php.net/fix.php?id=55157&r=trysnapshot52
Try a snapshot (PHP 5.3):            
https://bugs.php.net/fix.php?id=55157&r=trysnapshot53
Try a snapshot (trunk):              
https://bugs.php.net/fix.php?id=55157&r=trysnapshottrunk
Fixed in SVN:                        
https://bugs.php.net/fix.php?id=55157&r=fixed
Fixed in SVN and need be documented: 
https://bugs.php.net/fix.php?id=55157&r=needdocs
Fixed in release:                    
https://bugs.php.net/fix.php?id=55157&r=alreadyfixed
Need backtrace:                      
https://bugs.php.net/fix.php?id=55157&r=needtrace
Need Reproduce Script:               
https://bugs.php.net/fix.php?id=55157&r=needscript
Try newer version:                   
https://bugs.php.net/fix.php?id=55157&r=oldversion
Not developer issue:                 
https://bugs.php.net/fix.php?id=55157&r=support
Expected behavior:                   
https://bugs.php.net/fix.php?id=55157&r=notwrong
Not enough info:                     
https://bugs.php.net/fix.php?id=55157&r=notenoughinfo
Submitted twice:                     
https://bugs.php.net/fix.php?id=55157&r=submittedtwice
register_globals:                    
https://bugs.php.net/fix.php?id=55157&r=globals
PHP 4 support discontinued:          
https://bugs.php.net/fix.php?id=55157&r=php4
Daylight Savings:                    https://bugs.php.net/fix.php?id=55157&r=dst
IIS Stability:                       
https://bugs.php.net/fix.php?id=55157&r=isapi
Install GNU Sed:                     
https://bugs.php.net/fix.php?id=55157&r=gnused
Floating point limitations:          
https://bugs.php.net/fix.php?id=55157&r=float
No Zend Extensions:                  
https://bugs.php.net/fix.php?id=55157&r=nozend
MySQL Configuration Error:           
https://bugs.php.net/fix.php?id=55157&r=mysqlcfg
Try a snapshot (PHP 5.4):            
https://bugs.php.net/fix.php?id=55157&r=trysnapshot54

Reply via email to