|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2010-02-12 17:04 UTC] aleksey dot v dot korzun at gmail dot com
[2010-02-12 17:23 UTC] jani@php.net
[2010-02-12 18:49 UTC] clarity1285 at gmail dot com
[2010-02-20 01:00 UTC] php-bugs at lists dot php dot net
[2011-11-16 13:54 UTC] felipe@php.net
-Status: Open
+Status: Assigned
-Assigned To:
+Assigned To: colder
[2017-10-24 07:25 UTC] kalle@php.net
-Status: Assigned
+Status: Open
-Assigned To: colder
+Assigned To:
[2018-08-18 11:22 UTC] cmb@php.net
-Summary: CachingIterator::hasNext() does not return correct
value in some cases
+Summary: CachingIterator::hasNext() appears to return
incorrect values in some cases
-Status: Open
+Status: Verified
-Type: Bug
+Type: Documentation Problem
[2018-08-18 11:22 UTC] cmb@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 00:00:02 2025 UTC |
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