From: goetas at lignano dot it Operating system: PHP version: 5.3.0 PHP Bug Type: SPL related Bug description: LimitIterator with empty ArrayIterator
Description: ------------ iterating over an empty seekable iterator causes an unexpected exception. with actual implementation of LimitIterator::rewind() there is no way to do an empty loop over an empty ArrayIterator. i suggest this implementation for LimitIterator::rewind() method function rewind(){ $this->it->rewind(); $this->pos = 0; if($this->it->valid()){ // check for empty iterators $this->seek($this->offset); } } Reproduce code: --------------- $it = new ArrayIterator(array()); $limIt = new LimitIterator($it, 0, 5); foreach ($limIt as $item){ echo $item; } Expected result: ---------------- an empty loop Actual result: -------------- Uncaught exception 'OutOfBoundsException' with message 'Seek position 0 is out of range' -- Edit bug report at http://bugs.php.net/?id=49723&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=49723&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=49723&r=trysnapshot53 Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=49723&r=trysnapshot60 Fixed in SVN: http://bugs.php.net/fix.php?id=49723&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=49723&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=49723&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=49723&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=49723&r=needscript Try newer version: http://bugs.php.net/fix.php?id=49723&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=49723&r=support Expected behavior: http://bugs.php.net/fix.php?id=49723&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=49723&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=49723&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=49723&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=49723&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=49723&r=dst IIS Stability: http://bugs.php.net/fix.php?id=49723&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=49723&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=49723&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=49723&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=49723&r=mysqlcfg