Issues

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

Description

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

<pre class="highlight">
<?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)

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

string(5) "test2"

END

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

To solve this I created a new class Zend_Paginator_SerializableLimitIterator.

Comments

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.

Copyright

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