eZ Community » Forums » Developer » Cache block with subTreeExpiry in PHP...
expandshrink

Cache block with subTreeExpiry in PHP not working (bug?)

Cache block with subTreeExpiry in PHP not working (bug?)

Friday 17 February 2012 1:50:58 am - 5 replies

I thought I would try here first before logging a bug on issues.ez.no.

When I tried to create a cache block with subTreeExpiry in PHP following the code example in lib/eztemplate/classes/eztemplatecacheblock.php the cache was created and used correctly, but the subTreeExpiry does not seem to work.

After looking at eZTemplateCacheBlock::handle() I saw that the subTreeExpiry is considered only if the cache handler is eZDBFileHandler or eZDFSFileHandler. In my case the handler is eZFSFileHandler therefore the subTreeExpiry code would never kick in.

After swapping out:

if ( $cacheHandler instanceof eZDBFileHandler or $cacheHandler instanceof eZDFSFileHandler )
{
    $subtreeExpiry = eZTemplateCacheBlock::getSubtreeModification( $nodeID );
}

for a simple:

$subtreeExpiry = eZTemplateCacheBlock::getSubtreeModification( $nodeID );

The subTreeExpiry then seems to work correctly.

Looking at getSubtreeModification() this should be ok, since the method checks $nodeID and returns immediately if it is disabled.

Does anyone have any more detail on this? I'm wondering if the method was not updated perhaps, or maybe there are some specific implications as to why subTreeExpiry would only be considered for eZDBF and eZDFS handlers.

Any feedback would be appreciated.

Modified on Friday 17 February 2012 2:04:36 am by Benjamin Kroll

Friday 17 February 2012 4:48:26 pm

Could you check if you are using or not the eZFS2FileHandler ? (file.ini, file.ini.append.php somewhere...)

Friday 17 February 2012 5:16:01 pm

Ok, i think you're right, this algorithm can not work properly with eZFS & eZFS2

On each updated object :

  • template-block-cache is not update, becoz subtree_expiry always set the ignore_content_expiry to true
  • global-template-block-cache is not update ( global expiry, ezcache.php )
  • template-block cache files are not updated ( ezfs2=touch ) or deleted ( ezfs=unlink )

so... eZ Publish needs to query the SQL modified_subnode value in all cases ( eZFS, eZFS2, eZDB, eZDFS )

Maybe it could works on a specific situation, if the "global-template-block-cache" was not set before ( expiry.php was delete by a purge call, or never called a ezcache.php --clear-id=template-block...). Could you check if the "global-template-block-cache" is set inside your expiry.php ? and test again after removing this value ?

Modified on Friday 17 February 2012 5:27:54 pm by gilles guirand

Friday 17 February 2012 6:57:45 pm

Sorry Gilles, you lost me somewhere between a block and a cache... blunk.gif Emoticon

Friday 17 February 2012 7:43:47 pm

happy.gif Emoticon

The algorithm is a maze... but there is my option, more clearly :

This algorithm is trying to get the MAX value from 3 different timestamps :

  • template-block-cache : -1 ( if ignore_content_expiry or subtree_expiry )
  • getSubtreeModification() : -1 with ezfs or ezfs2 (that's a part of the issue)
  • global-template-block-cache : -1 if this expiry.php value is not set (that's a part of the issue)

If global-template-block-cache is not set : MAX value = -1, so ezfs / ezfs2 processCache function should ignore this parameter, right ? So nothing happens...

If global-template-block-cache is set with a timestamp : MAX value = global-template-block-cache, so ezfs / ezfs2 processCache function use this probably old value, right ? So nothing happens...

Sunday 19 February 2012 3:21:15 pm

I tested as you suggested above Gilles and "global-template-block-cache" was set in expiry.php.
After removing the entry and then re-testing, the subTreeExpiry still seems to work correctly with the modified code I've posted above.

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from