ZF-8084: Segmentation Fault with Zend_Paginator_Adapter_Iterator + Zend_Cache


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


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)

php test.php
string(4) "test"

string(5) "test2"


Second run (cached)

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: http://bugs.php.net/bug.php?id=49906

To solve this I created a new class Zend_Paginator_SerializableLimitIterator.


added patch

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

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