ZF-8084: Segmentation Fault with Zend_Paginator_Adapter_Iterator + Zend_Cache

Issue Type: Bug Created: 2009-10-17T03:29:39.000+0000 Last Updated: 2009-11-25T01:43:00.000+0000 Status: Resolved Fix version(s): - 1.9.7 (11/Jan/10)

Reporter: Marc Bennewitz (private) (mabe) Assignee: Marc Bennewitz (private) (mabe) Tags: - Zend_Paginator

Related issues: Attachments: - ZF-8084.patch


If you use the iterator adapter and a serializing cache like the following you will crash php:

<pre class="highlight">

require_once 'Zend/Loader/Autoloader.php';
$autoloader = Zend_Loader_Autoloader::getInstance();
$view = new Zend_View();

try {
    $frontendOptions    = array(
        'caching' => true,
        'lifetime' => 72000,
        'automatic_serialization' => true
    $backendOptions = array(
        'cache_dir' => '/tmp/invite_vcfront' // Directory where to put the cache files
    $cache = Zend_Cache::factory('Core','File', $frontendOptions,$backendOptions);

    $it = new ArrayIterator(array('test' => 'test', 'test2' => 'test2'));
    $paginator = Zend_Paginator::factory($it);
    // var_dump($paginator->getIterator());
    foreach($paginator as $page){
        echo var_dump($page)."\n";

} catch (Exception $e) {
    echo $e;

echo "END\n";

First run (not cached)

<pre class="literal">
php test.php
string(4) "test"

string(5) "test2"


Second run (cached)

<pre class="literal">
php test.php
Segmentation fault

After cleaning cache this restarts on first run

The problem is that Zend_Paginator caches an instance of LimitIterator where is a bug in php:

To solve this I created a new class Zend_Paginator_SerializableLimitIterator.


Posted by Marc Bennewitz (private) (mabe) on 2009-10-17T03:41:20.000+0000

added patch

Posted by Marc Bennewitz (private) (mabe) on 2009-10-22T14:23:17.000+0000

patch implemented in r18670 (added testcase Zend_Paginator_Adapter_IteratorTest::testGetItemsSerializable)

Posted by Carlos Buenosvinos (carlos.buenosvinos) on 2009-11-25T00:49:43.000+0000

"unserialize" DocBlock says "@paran". It should be "@param"

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.