Bug #50981 [Opn->Asn]: CachingIterator::hasNext() does not return correct value in some cases
Edit report at https://bugs.php.net/bug.php?id=50981&edit=1
ID: 50981
Updated by: felipe@php.net
Reported by: clarity1285 at gmail dot com
Summary: CachingIterator::hasNext() does not return correct
value in some cases
-Status: Open
+Status: Assigned
Type: Bug
Package: SPL related
Operating System: Mac OS X
PHP Version: 5.3.1
-Assigned To:
+Assigned To: colder
Block user comment: N
Private report: N
Previous Comments:
------------------------------------------------------------------------
[2010-02-20 01:00:01] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
------------------------------------------------------------------------
[2010-02-12 18:49:14] clarity1285 at gmail dot com
Tested with PHP 5.3.3-dev snapshot provided, and the issue is still
reproducible.
------------------------------------------------------------------------
[2010-02-12 17:23:50] jani@php.net
Please try using this snapshot:
http://snaps.php.net/php5.3-latest.tar.gz
For Windows:
http://windows.php.net/snapshots/
------------------------------------------------------------------------
[2010-02-12 17:04:55] aleksey dot v dot korzun at gmail dot com
I'm experiencing the same issue.
------------------------------------------------------------------------
[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 https://bugs.php.net/bug.php?id=50981&edit=1
Thread (7 messages)