Zend Framework

Segmentation Fault with Zend_Paginator_Adapter_Iterator + Zend_Cache

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.9.4
  • Fix Version/s: 1.9.7
  • Component/s: Zend_Paginator
  • Labels:
    None

Description

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

<?php


set_include_path('/tmp/zf/trunk/library/');
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);
    Zend_Paginator::setCache($cache);

    $it = new ArrayIterator(array('test' => 'test', 'test2' => 'test2'));
    $paginator = Zend_Paginator::factory($it);
    $paginator->setItemCountPerPage(10);
    $paginator->setCurrentPageNumber(1);
    $paginator->setView($view);
    // 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"

END

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.

Activity

Hide
Marc Bennewitz (private) added a comment -

added patch

Show
Marc Bennewitz (private) added a comment - added patch
Hide
Marc Bennewitz (private) added a comment -

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

Show
Marc Bennewitz (private) added a comment - patch implemented in r18670 (added testcase Zend_Paginator_Adapter_IteratorTest::testGetItemsSerializable)
Hide
Carlos Buenosvinos added a comment -

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

Show
Carlos Buenosvinos added a comment - "unserialize" DocBlock says "@paran". It should be "@param"

People

Vote (1)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: