FAQ
Edit report at http://pear.php.net/bugs/bug.php?id=16162&edit=1

ID: 16162
Updated by: tacker@php.net
Reported By: php at alanhogan dot com
Summary: Support for nested output capturing
Status: Open
Type: Feature/Change Request
Package: Cache_Lite
Operating System: N/A
Package Version: 1.7.7
PHP Version: 5.2.9
Roadmap Versions:
New Comment:

I've added a new class (Cache_Lite_NestedOutput) to handle this.

Please try it from CVS [1] and report back to me if this solution fixes
your problem.

See [2] for an example.

It is important to note that NestedOutput has to return the cached data
instead of echoing it, otherwise the contents would bubble up to the
parent cache. This means that you have to change your code to reflect
this.

[1] http://cvs.php.net/viewvc.cgi/pear/Cache_Lite/
[2]
http://cvs.php.net/viewvc.cgi/pear/Cache_Lite/tests/NestedOutputTest.php?view=markup


Previous Comments:
------------------------------------------------------------------------

[2009-04-30 08:06:53] php_alan

Description:
------------
Very weird and hard-to-debug problems can occur when caching a whole
page and parts of a page.

Using output caching is superior to function caching because sometimes

the nested part of the page is shared with other pages and/or requires
a
(series of) pages to be included for the function to run; using output

caching means those files need never load.

Additionally, since no error is thrown when Cache_Lite is "abused" this

way, and the error is hard to detect (you may need a high cache time
and/or rapid reloading and lax client-side caching to detect it), this
is a
potential security issue as cache objects may include unexpected
information.

Finally, since PHP’s output buffering supports nesting, it is
logical to
imagine Cache_Lite can/should support it, as well.

Test script:
---------------
if(!$cache->start('foo', 'bar')) {

// ... output...

//nested cache:
if(!$cache->start('baz', 'bot')) {
// ... nested output ...
$cache->end();
}
//end nested cache

// more output

$cache->end();
}

Expected result:
----------------
The nested output cache should only cache a small chunk of the page;
the
outer output cache should cache the whole thing

Actual result:
--------------
The inner cache may actually include the whole page (outer cache).

------------------------------------------------------------------------

Search Discussions

  • Tacker at May 1, 2009 at 1:26 pm
    Edit report at http://pear.php.net/bugs/bug.php?id=16162&edit=1

    ID: 16162
    Updated by: tacker@php.net
    Reported By: php at alanhogan dot com
    Summary: Support for nested output capturing
    -Status: Open
    +Status: Feedback
    Type: Feature/Change Request
    Package: Cache_Lite
    Operating System: N/A
    Package Version: 1.7.7
    PHP Version: 5.2.9
    -Assigned To:
    +Assigned To: tacker
    Roadmap Versions:
    New Comment:

    -Status: Open
    +Status: Feedback
    -Assigned To:
    +Assigned To: tacker




    Previous Comments:
    ------------------------------------------------------------------------

    [2009-05-01 15:25:12] tacker

    I've added a new class (Cache_Lite_NestedOutput) to handle this.

    Please try it from CVS [1] and report back to me if this solution fixes
    your problem.

    See [2] for an example.

    It is important to note that NestedOutput has to return the cached data
    instead of echoing it, otherwise the contents would bubble up to the
    parent cache. This means that you have to change your code to reflect
    this.

    [1] http://cvs.php.net/viewvc.cgi/pear/Cache_Lite/
    [2]
    http://cvs.php.net/viewvc.cgi/pear/Cache_Lite/tests/NestedOutputTest.php?view=markup

    ------------------------------------------------------------------------

    [2009-04-30 08:06:53] php_alan

    Description:
    ------------
    Very weird and hard-to-debug problems can occur when caching a whole
    page and parts of a page.

    Using output caching is superior to function caching because sometimes

    the nested part of the page is shared with other pages and/or requires
    a
    (series of) pages to be included for the function to run; using output

    caching means those files need never load.

    Additionally, since no error is thrown when Cache_Lite is "abused" this

    way, and the error is hard to detect (you may need a high cache time
    and/or rapid reloading and lax client-side caching to detect it), this
    is a
    potential security issue as cache objects may include unexpected
    information.

    Finally, since PHP’s output buffering supports nesting, it is
    logical to
    imagine Cache_Lite can/should support it, as well.

    Test script:
    ---------------
    if(!$cache->start('foo', 'bar')) {

    // ... output...

    //nested cache:
    if(!$cache->start('baz', 'bot')) {
    // ... nested output ...
    $cache->end();
    }
    //end nested cache

    // more output

    $cache->end();
    }

    Expected result:
    ----------------
    The nested output cache should only cache a small chunk of the page;
    the
    outer output cache should cache the whole thing

    Actual result:
    --------------
    The inner cache may actually include the whole page (outer cache).

    ------------------------------------------------------------------------

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
categoriesphp
postedMay 1, '09 at 1:25p
activeMay 1, '09 at 1:26p
posts2
users1
websitepear.php.net

1 user in discussion

Tacker: 2 posts

People

Translate

site design / logo © 2021 Grokbase