- enhancement an expire_time of -1 in clearCache() and clearAllCache() will delete outdated cache files

by their individual cache_lifetime used at creation (forum topic 24310)
This commit is contained in:
Uwe.Tews@googlemail.com
2013-05-26 10:50:13 +00:00
parent 6b5b06564f
commit 00c034b593
2 changed files with 258 additions and 245 deletions

View File

@@ -1,4 +1,8 @@
===== trunk ===== ===== trunk =====
26.05.2013
- enhancement an expire_time of -1 in clearCache() and clearAllCache() will delete outdated cache files
by their individual cache_lifetime used at creation (forum topic 24310)
21.05.2013 21.05.2013
- bugfix modifier strip_tags:true was compiled into wrong code (Forum Topic 24287) - bugfix modifier strip_tags:true was compiled into wrong code (Forum Topic 24287)
- bugfix /n after ?> in Smarty.class.php did start output buffering (Issue 138) - bugfix /n after ?> in Smarty.class.php did start output buffering (Issue 138)

View File

@@ -1,5 +1,5 @@
<?php <?php
/** /**
* Smarty Internal Plugin CacheResource File * Smarty Internal Plugin CacheResource File
* *
* @package Smarty * @package Smarty
@@ -8,7 +8,7 @@
* @author Rodney Rehm * @author Rodney Rehm
*/ */
/** /**
* This class does contain all necessary methods for the HTML cache on file system * This class does contain all necessary methods for the HTML cache on file system
* *
* Implements the file system as resource for the HTML cache Version ussing nocache inserts. * Implements the file system as resource for the HTML cache Version ussing nocache inserts.
@@ -16,7 +16,7 @@
* @package Smarty * @package Smarty
* @subpackage Cacher * @subpackage Cacher
*/ */
class Smarty_Internal_CacheResource_File extends Smarty_CacheResource { class Smarty_Internal_CacheResource_File extends Smarty_CacheResource {
/** /**
* populate Cached Object with meta data from Resource * populate Cached Object with meta data from Resource
@@ -210,9 +210,18 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource {
} }
} }
// expired ? // expired ?
if (isset($exp_time) && $_time - @filemtime($_file) < $exp_time) { if (isset($exp_time)) {
if ($exp_time < 0) {
preg_match('#\'cache_lifetime\' =>\s*(\d*)#', file_get_contents($_file), $match);
if ($_time < (@filemtime($_file) + $match[1])) {
continue; continue;
} }
} else {
if ($_time - @filemtime($_file) < $exp_time) {
continue;
}
}
}
$_count += @unlink((string) $_file) ? 1 : 0; $_count += @unlink((string) $_file) ? 1 : 0;
} }
} }
@@ -261,6 +270,6 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource {
$cached->is_locked = false; $cached->is_locked = false;
@unlink($cached->lock_id); @unlink($cached->lock_id);
} }
} }
?> ?>