Issues

ZF-8019: Zend_Paginator get Cache ID Error

Issue Type: Bug Created: 2009-10-06T02:22:22.000+0000 Last Updated: 2010-05-26T04:19:52.000+0000 Status: Resolved Fix version(s): - 1.10.5 (26/May/10)

Reporter: Minh Son Nguyen (conan1212) Assignee: Marco Kaiser (bate) Tags: - Zend_Paginator

Related issues: - ZF-6989

Attachments:

Description

File Zend_Paginator.php method: public function getItemsByPage($pageNumber) on line 737

issue:

Method will check if cache enable and cache ID exists it will return the cached data.

<pre class="highlight">
if ($this->_cacheEnabled()) {
            $data = self::$_cache->load($this->_getCacheId($pageNumber));
            if ($data !== false) {
                return $data;
            }
        }

If cache is enable but does not exists It will get data and cached with a cache ID.

<pre class="highlight">
 if ($this->_cacheEnabled()) {
            self::$_cache->save($items, $this->_getCacheId($pageNumber), array($this->_getCacheInternalId()));
        }

But when I echo $this->_getCacheId($pageNumber) at first check step and save cache step It gives two defference cache ID so Zend_Paginator cache feature does not work, It just generate a file or overide cached file without using cached data . Here my code

<pre class="highlight">
if ($this->_cacheEnabled()) {
//ouput cache name for checking it
    echo $this->_getCacheId($pageNumber) .'<br></br>';
    $data = self::$_cache->load($this->_getCacheId($pageNumber));
    if ($data !== false) {
        return $data;
    }
}
        
 if ($this->_cacheEnabled()) {
//ouput cache name for checking it
    echo $this->_getCacheId($pageNumber) .'<br></br>';
    self::$_cache->save($items, $this->_getCacheId($pageNumber), array($this->_getCacheInternalId()));
}

I have checked It on Zend_Paginator_Adapter_DbSelect with the both Pdo_mysql and MySqli Db Adaptors and Zend_Db option profiler was turned off, Please check and fix this problem plz

Comments

Posted by wl nroe (nroe) on 2009-12-24T22:49:45.000+0000

this is my way,

\_select; } } ?> getItemCountPerPage(); return md5(serialize( array( strval($this->getAdapter()->getSelect()->limit()), ($pageNumber - 1) \* $item\_count\_per\_page, $item\_count\_per\_page))); } } ?>

Posted by Martin Meißner (meisii) on 2010-03-12T17:11:19.000+0000

This issue is still open in 1.10.2

Thanks @ wl nroe

Your solution could resolve the problem. I tested a shorter version and it seems to work well.

<pre class="literal">
<?php
class My_Paginator extends Zend_Paginator
{
    protected function _getCacheInternalId()
    {
        return md5(serialize(strval($this->getAdapter()->getSelect()->limit())));
    }
}

Posted by Marco Kaiser (bate) on 2010-05-26T02:40:36.000+0000

@Martin Meißner your solution is not perfect, there are some more adapters without the database interface

Posted by Marco Kaiser (bate) on 2010-05-26T04:19:52.000+0000

fixed with r22302

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts