Issue

ZF-9947: Zend_Paginator - problem with _getCacheInternalId

Issue Type: Bug Created: 2010-06-04T10:27:10.000+0000 Last Updated: 2011-11-08T12:06:09.000+0000 Status: Reopened Fix version(s): Reporter: Sebastian Zan (subey) Assignee: Ramon Henrique Ornelas (ramon) Tags: - Zend_Paginator

  • zf-caretaker-adamlundrigan

Related issues: - ZF-6989

Attachments:

Description

  1. My controller:

         public function indexAction()
         {
    
             $typeTopics = $this->_getParam('type');
             $select = $topics->prepareSelect( array($typeTopics=>0) );
    
             $paginator = new Zend_Paginator( new Zend_Paginator_Adapter_DbTableSelect( $select ) );
             Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination.phtml');
             $paginator->setCurrentPageNumber( $this->getRequest()->getParam( 'page', 1 ) );
             $paginator->setItemCountPerPage( 40 );
             $paginator->setPageRange(32);
    
             $this->view->paginator = $paginator;
    
         }
    
    
  2. In Zend_Paginator added :

         protected function _getCacheInternalId()
         {
             echo md5(serialize(array(
                 spl_object_hash($this->getAdapter()),
                 $this->getItemCountPerPage()
             ))).'

    '; return md5(serialize(array( spl_object_hash($this->getAdapter()), $this->getItemCountPerPage() ))); }
  3. I removed all cache

  4. Refresh page with url params: /type/new/page/1: _getCacheInternalId return: 322da30ae524a49ef490e50e873ab732 /type/popular/page/1: _getCacheInternalId return: b787e582a878f61ec149875f5484cfd6 ok we have different hash

  5. I reload pages again and now paginator reading from cache: /type/new/page/1: _getCacheInternalId return: b787e582a878f61ec149875f5484cfd6 /type/popular/page/1: _getCacheInternalId return: b787e582a878f61ec149875f5484cfd6 hash is the same for both urls, if disable cache everythings works good :(

Comments

Posted by Wolfgang Bertl (fame23) on 2010-07-13T12:09:37.000+0000

I have the same problem in 1.10.6.

I can't say why, but on a Windows 7 computer I get a different internal cache id but on a computer with linux debian I always get the same internal cache id.

Posted by Wolfgang Bertl (fame23) on 2010-07-13T12:47:18.000+0000

Edit: On the Windows 7 is PHP version 5.3.1 installed and on the linux debian PHP version 5.2.8. Is it possible, that the PHP version is the problem?

Posted by Martin Mei├čner (meisii) on 2010-08-18T05:40:54.000+0000

Have a look on my comment for issue ZF-9940. Caching should now working fine. This issue can be closed.

Posted by Ramon Henrique Ornelas (ramon) on 2010-08-20T17:15:19.000+0000

Fixed by [~bate] in revision r22828.

Posted by Rich Tibbett (richt) on 2011-10-05T12:58:28.000+0000

I'm still observing this bug in the latest release.

I took a look in to this issue and managed to hack caching to work as expected in Zend_Paginator as follows (diff to trunk r24489):

Index: library/Zend/Paginator.php

--- library/Zend/Paginator.php (revision 24490) +++ library/Zend/Paginator.php (working copy) @@ -772,8 +772,10 @@ { $pageNumber = $this->normalizePageNumber($pageNumber);

  • $cache_id = $this->_getCacheId($pageNumber);
  • if ($this->_cacheEnabled()) {
  • $data = self::$_cache->load($this->_getCacheId($pageNumber));
  • $data = self::$_cache->load($cache_id); if ($data !== false) { return $data; }

@@ -794,7 +796,7 @@ }

 if ($this->_cacheEnabled()) {
  • self::$_cache->save($items, $this->_getCacheId($pageNumber), array($this->_getCacheInternalId()));

  • self::$_cache->save($items, $cache_id, array($this->_getCacheInternalId())); }

    return $items;


Not sure if this is the solution but it worked for me.

Posted by Adam Lundrigan (adamlundrigan) on 2011-10-17T02:53:33.000+0000

Reopened due to comments

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2017 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