Edit report at http://bugs.php.net/bug.php?id=53119&edit=1
ID: 53119
Comment by: marc-bennewitz at arcor dot de
Reported by: marc-bennewitz at arcor dot de
Summary: LimitIterator(ArrayIterator)->seek() doesn't work
correctly after OutOfBoundsE
Status: Open
Type: Bug
Package: SPL related
Operating System: Linux
PHP Version: 5.3.3
Block user comment: N
New Comment:
The LimitIterator should have the same behavior as the inner iterator
(in this example ArrayIterator) but on ArrayIterator there is no need to
call rewind after an Exception.
Previous Comments:
------------------------------------------------------------------------
[2010-10-21 11:50:29] [email protected]
The exception leaves the iterator in undefined behavior. That is
expected.
------------------------------------------------------------------------
[2010-10-20 20:47:02] marc-bennewitz at arcor dot de
Description:
------------
Seeking after an OutOfBoundException doesn't work without call of
rewind.
With php < 5.3 it works as expected.
Test script:
---------------
$it = new ArrayIterator(array('zf9396', 'foo', null));
$it->rewind();
try {
$it->seek(3);
} catch (OutOfBoundsException $e) {
var_dump($it->key());
$it->seek(0);
var_dump($it->key());
}
$lit = new LimitIterator($it, 0, 10);
try {
$lit->seek(3);
} catch (OutOfBoundsException $e) {
var_dump($lit->key());
$lit->seek(0);
var_dump($lit->key());
}
Expected result:
----------------
NULL
int(0)
NULL
int(0)
Actual result:
--------------
NULL
int(0)
NULL
NULL
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=53119&edit=1