Issues

ZF-11672: Paginator SerializableLimitIterator throws OutOfBoundsException

Description

When Session is enabled i get the following exception from Zend_Paginator_SerializableLimitIterator:


Uncaught exception 'OutOfBoundsException' with message 'Cannot seek to 10 which is behind offset 0 plus count 10' in C:\Zend\ZendServer\share\ZendFramework\library\Zend\Paginator\SerializableLimitIterator.php:80
Stack trace:
#0 C:\Zend\ZendServer\share\ZendFramework\library\Zend\Paginator\SerializableLimitIterator.php(80): LimitIterator->seek(10)
#1 [internal function]: Zend_Paginator_SerializableLimitIterator->unserialize('a:4:{s:2:"it";O...')
#2 C:\Zend\ZendServer\share\ZendFramework\library\Zend\Session.php(480): session_start()
#3 C:\Zend\Apache2\htdocs\pikee_zf\application\Bootstrap.php(12): Zend_Session::start()
#4 C:\Zend\ZendServer\share\ZendFramework\library\Zend\Application\Bootstrap\BootstrapAbstract.php(667): Bootstrap->_initSession()
#5 C:\Zend\ZendServer\share\ZendFramework\library\Zend\Application\Bootstrap\BootstrapAbstract.php(620): Zend_Application_Bootstrap_BootstrapAbstract->_executeResource('session')
#6 C:\Zend\ZendServer\share\ZendFramework\library\Zend\Application\Bootstrap\BootstrapAb in C:\Zend\ZendServer\share\ZendFramework\library\Zend\Paginator\SerializableLimitIterator.php

I guess the reason is that Zend_Paginator_SerializableLimitIterator tries to seek to 10 when there are only ten items - instead it should seek to 9. Fixed that in the attached patch.

Comments

Hmm - could not find where to upload the patch - so here it is:


80c80
<         $this->seek($dataArr['pos']+$dataArr['offset']);
---
>         $this->seek(min($dataArr['pos']+$dataArr['offset'], $dataArr['count'] - 1));