Bug #55157 [NEW]: ArrayIterator::offsetUnset(); does not work correctly
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
Thread (15 messages)
- olav at fwt dot no
- colder@php.netBug #55157 [Opn->Asn]: ArrayIterator::offsetUnset(); does not work correctly
- joey@php.netBug #55157 [Asn]: ArrayIterator::offsetUnset(); does not work correctly
- joey@php.netBug #55157 [Asn]: ArrayIterator::offsetUnset(); does not work correctly
- gergo at gergoerdosi dot comBug #55157 [Com]: ArrayIterator::offsetUnset(); does not work correctly
- gergo at gergoerdosi dot comBug #55157 [Com]: ArrayIterator::offsetUnset(); does not work correctly
- levim@php.netBug #55157 [Com]: ArrayIterator::offsetUnset(); does not work correctly
- jan dot kahoun at heureka dot czBug #55157 [Com]: ArrayIterator::offsetUnset(); does not work correctly
- mw dot wanrooij at vodafonevast dot nlBug #55157 [Com]: ArrayIterator::offsetUnset(); does not work correctly
- kalle@php.netBug #55157 [Asn->Opn]: ArrayIterator::offsetUnset(); does not work correctly
- alexinbeijing at gmail dot comBug #55157 [Com]: ArrayIterator::offsetUnset(); does not work correctly
- alexinbeijing@gmail.comBug #55157 [PATCH]: ArrayIterator::offsetUnset(); does not work correctly
- alexinbeijing at gmail dot comBug #55157 [Com]: ArrayIterator::offsetUnset(); does not work correctly
- cmb@php.netBug #55157 [Csd]: ArrayIterator::offsetUnset(); does not work correctly
- cmb@php.netBug #55157 [Opn->Csd]: ArrayIterator::offsetUnset(); does not work correctly