ID: 50981
Comment by: aleksey dot v dot korzun at gmail dot com
Reported By: clarity1285 at gmail dot com
Status: Open
Bug Type: SPL related
Operating System: Mac OS X
PHP Version: 5.3.1
New Comment:
I'm experiencing the same issue.
Previous Comments:
------------------------------------------------------------------------
[2010-02-09 23:05:48] clarity1285 at gmail dot com
Description:
------------
When there are 11 total items and you use a LimitIterator to get the
first 10, CachingIterator::hasNext() returns false even though there
are
more than 10 items in the initial set.
If there are 12 total items it works as expected.
Reproduce code:
---------------
$items = new ArrayObject(range(1,11));
echo 'there are ' . $items->count() . ' total items' . "\r\n";
$cachingIterator = new CachingIterator($items->getIterator());
$limitIterator = new LimitIterator($cachingIterator, 0, 10);
$i = 0;
foreach ($limitIterator as $item) {
++$i;
}
echo 'first page has ' . $i . ' items' . "\r\n";
if ($cachingIterator->hasNext()) {
echo 'there is a next page';
} else {
echo 'there is no next page';
}
Expected result:
----------------
The code should output:
there are 11 total items
first page has 10 items
there is a next page
Actual result:
--------------
The code outputs:
there are 11 total items
first page has 10 items
there is no next page
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=50981&edit=1