php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53119 LimitIterator(ArrayIterator)->seek() doesn't work correctly after OutOfBoundsE
Submitted: 2010-10-20 20:47 UTC Modified: 2011-11-16 14:19 UTC
From: marc-bennewitz at arcor dot de Assigned: colder
Status: Assigned Package: SPL related
PHP Version: 5.3.3 OS: Linux
Private report: No CVE-ID:
Have you experienced this issue?
Rate the importance of this bug to you:

 [2010-10-20 20:47 UTC] 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-10-21 11:50 UTC] johannes@php.net
The exception leaves the iterator in undefined behavior. That is expected.
 [2010-10-21 18:22 UTC] marc-bennewitz at arcor dot de
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.
 [2011-11-16 14:19 UTC] felipe@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: colder
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Thu Apr 17 03:01:55 2014 UTC