From: clarity1285 at gmail dot com
Operating system: Mac OS X
PHP version: 5.3.1
PHP Bug Type: SPL related
Bug description: CachingIterator::hasNext() does not return correct value in
some cases
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 bug report at http://bugs.php.net/?id=50981&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=50981&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=50981&r=trysnapshot53
Try a snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=50981&r=trysnapshot60
Fixed in SVN:
http://bugs.php.net/fix.php?id=50981&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=50981&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=50981&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=50981&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=50981&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=50981&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=50981&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=50981&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=50981&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=50981&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=50981&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=50981&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=50981&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=50981&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=50981&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=50981&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=50981&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=50981&r=mysqlcfg