ZF-10260: Zend_Paginator adapter's count()-method is called twice when using the paginationcontrol view helper
Description
When using the paginationcontrol view helper, the count()-method on the adapter get's called twice through the methods _calculatePageCount() and getTotalItemCount().
protected function _calculatePageCount()
{
return (integer) ceil($this->getAdapter()->count() / $this->getItemCountPerPage());
}
and
public function getTotalItemCount()
{
return count($this->getAdapter());
}
The return value of the adapter's count()-method should be held in a class member:
public function getTotalItemCount()
{
if($this->_totalItemCount === null)
{
$this->_totalItemCount = count($this->getAdapter());
}
return $this->_totalItemCount;
}
Comments
Posted by Martin Meißner (meisii) on 2010-08-21T15:41:13.000+0000
I agree with that.
The affected functions look currently like this:
These could be changed as follows:
This works fine for me.