ZF-11318: Zend_Paginator cache ( related to ZF-10447 )

Issue Type: Bug Created: 2011-04-22T23:02:36.000+0000 Last Updated: 2012-05-05T02:34:12.000+0000 Status: Closed Fix version(s): Reporter: Robert Fisher (fwrmedia) Assignee: Adam Lundrigan (adamlundrigan) Tags: - Zend_Paginator

Related issues: - ZF-6989



This is related to

But I hope this may help.

Using the standard serialization of the adapter I noticed two things ( other than the DB reconnect ): - 1) Zend_Paginator::_getCacheInternalId() is called three times ( in my usage ), the first md5 serialization differs from the other two, probably because the last two modify the _select of the adapter. 2) The md5 changes on every subsequent page load, why I don't know at this stage.

I tried moving away from the serialization of the object to a string representation of the _select of the adapter ( added a getSelect() method ) this had the same effect as 1) but the subsequent loads did provide the same hashed strings, which was an improvement.

I then added a static cache within the Zend_Paginator::_getCacheInternalId() method which stored the initial hash ( probably the one before the paging changed the select ) and this seems to work.

<pre class="highlight">
    protected function _getCacheInternalId()
        static $cache = array();
        $adapter_namespace = get_class( $this->getAdapter() );
        if ( !array_key_exists( $adapter_namespace, $cache ) ) {
            $cache[$adapter_namespace] = md5(serialize(array(
        return $cache[$adapter_namespace];

The page number is still added to the md5 so it should still be unique.

Whether this is a valid solution I really don't know at this stage but thought it worth mentioning. [edit]Code modified to allow caches for different adapter namespaces[/edit]


No comments to display

Have you found an issue?

See the Overview section for more details.


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

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