|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #53926 LimitIterator::rewind() problem
Submitted: 2011-02-04 18:47 UTC Modified: 2017-10-24 09:12 UTC
From: maciej at maciej-kaczmarek dot pl Assigned: salathe (profile)
Status: Assigned Package: SPL related
PHP Version: Irrelevant OS: Irrelevant
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
49 + 29 = ?
Subscribe to this entry?

 [2011-02-04 18:47 UTC] maciej at maciej-kaczmarek dot pl
When you using LimitIterator with offset that is larger or equal than inner 
iterator collection size and you invoke rewind() on LimitIterator then you get 
out of bounds exception.

You can solve that problem by handle exception from inner iterator's rewind() in 

Test script:
$some_array = array('foo', 'bar');
$iter = new ArrayIterator($some_array);
$limitIter = new LimitIterator($iter, 2);

foreach($limitIter as $value) {
    echo $value;

echo 'OK';

Expected result:
only 'OK'

Actual result:
PHP Fatal error:  Uncaught exception 'OutOfBoundsException' with message 'Seek 
position 2 is out of range' in index.php:6

Stack trace:
#0 [internal function]: ArrayIterator->seek(2)
#1 index.php(6): LimitIterator->rewind()
#2 {main}


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2011-02-08 17:45 UTC]
-Type: Bug +Type: Documentation Problem
 [2011-02-08 17:47 UTC]
I'm posting this on pastebin due to some objections of the bug tracker:
 [2012-04-27 23:20 UTC]
-Assigned To: +Assigned To: salathe
 [2017-10-24 07:58 UTC]
-Status: Assigned +Status: Open -Assigned To: salathe +Assigned To:
 [2017-10-24 09:13 UTC]
-Status: Open +Status: Assigned -Assigned To: +Assigned To: salathe
 [2017-10-24 09:13 UTC]
Re-assigning to me to keep visibility.
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sat Sep 19 17:01:25 2020 UTC