[PHPTAL] Verry little patch for phptal:cache

Julien Fredon julien.fredon at imaginance.com
Tue Dec 4 12:49:34 CET 2007


I've got an error with phptal:cache (php in stric mode) when the cache 
file doesn't exist :

filemtime() [function.filemtime 
<http://serveur:8166/function.filemtime>]: stat failed for 
templates_compilation/tpl_1_1_9f04e50e8bb416be9d5d0622ef9e2ece2.phpd7ba92263d785bb278522b594a8a8ae6


This little patch fix the problem for me.

-- 
Jules
-------------- section suivante --------------
Index: C:/Documents and Settings/Julien/workspace_v3.3/PHPTAL/classes/PHPTAL/Php/Attribute/PHPTAL/Cache.php
===================================================================
--- C:/Documents and Settings/Julien/workspace_v3.3/PHPTAL/classes/PHPTAL/Php/Attribute/PHPTAL/Cache.php	(revision 316)
+++ C:/Documents and Settings/Julien/workspace_v3.3/PHPTAL/classes/PHPTAL/Php/Attribute/PHPTAL/Cache.php	(working copy)
@@ -74,7 +74,7 @@
              $this->tag->generator->doSetVar($this->cache_tag, '('.$code.')."@".' . $old_cache_tag );
         }
     
-        $cond = 'time() - '.$cache_len.' > @filemtime(__FILE__.md5('.$this->cache_tag.'))';
+        $cond = 'file_exists(__FILE__.md5('.$this->cache_tag.')) || time() - '.$cache_len.' > @filemtime(__FILE__.md5('.$this->cache_tag.'))';
 
         $this->tag->generator->doIf($cond);
         $this->tag->generator->doEval('ob_start()');


More information about the PHPTAL mailing list