From 7e7591f6c0f6785c57966b9d52e53836e4dd1825 Mon Sep 17 00:00:00 2001 From: uwetews Date: Sun, 27 Dec 2015 03:28:26 +0100 Subject: [PATCH] new _clearTemplateCache() method --- libs/Smarty.class.php | 8 ++++++++ libs/sysplugins/smarty_cacheresource.php | 11 ----------- .../smarty_internal_method_clearallcache.php | 2 +- libs/sysplugins/smarty_internal_method_clearcache.php | 2 +- .../smarty_internal_method_clearcompiledtemplate.php | 5 ++--- 5 files changed, 12 insertions(+), 16 deletions(-) diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index ec88a6e0..9bee638e 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -1193,6 +1193,14 @@ class Smarty extends Smarty_Internal_TemplateBase return $path; } + /** + * Empty template objects cache + */ + public function _clearTemplateCache() { + $this->_cache['isCached'] = array(); + $this->_cache['tplObjects'] = array(); + } + /** * @param boolean $compile_check */ diff --git a/libs/sysplugins/smarty_cacheresource.php b/libs/sysplugins/smarty_cacheresource.php index 8561ce08..ef0324f9 100644 --- a/libs/sysplugins/smarty_cacheresource.php +++ b/libs/sysplugins/smarty_cacheresource.php @@ -207,15 +207,4 @@ abstract class Smarty_CacheResource // give up throw new SmartyException("Unable to load cache resource '{$type}'"); } - - /** - * Invalid Loaded Cache Files - * - * @param Smarty $smarty Smarty object - */ - public function invalidLoadedCache(Smarty $smarty) - { - $smarty->_cache['isCached'] = array(); - $smarty->_cache['tplObjects'] = array(); - } } diff --git a/libs/sysplugins/smarty_internal_method_clearallcache.php b/libs/sysplugins/smarty_internal_method_clearallcache.php index 6ae0af15..5879f9a0 100644 --- a/libs/sysplugins/smarty_internal_method_clearallcache.php +++ b/libs/sysplugins/smarty_internal_method_clearallcache.php @@ -32,9 +32,9 @@ class Smarty_Internal_Method_ClearAllCache */ public function clearAllCache(Smarty $smarty, $exp_time = null, $type = null) { + $smarty->_clearTemplateCache(); // load cache resource and call clearAll $_cache_resource = Smarty_CacheResource::load($smarty, $type); - $_cache_resource->invalidLoadedCache($smarty); return $_cache_resource->clearAll($smarty, $exp_time); } } \ No newline at end of file diff --git a/libs/sysplugins/smarty_internal_method_clearcache.php b/libs/sysplugins/smarty_internal_method_clearcache.php index 063c57cd..74d3e9d5 100644 --- a/libs/sysplugins/smarty_internal_method_clearcache.php +++ b/libs/sysplugins/smarty_internal_method_clearcache.php @@ -35,9 +35,9 @@ class Smarty_Internal_Method_ClearCache */ public function clearCache(Smarty $smarty, $template_name, $cache_id = null, $compile_id = null, $exp_time = null, $type = null) { + $smarty->_clearTemplateCache(); // load cache resource and call clear $_cache_resource = Smarty_CacheResource::load($smarty, $type); - $_cache_resource->invalidLoadedCache($smarty); return $_cache_resource->clear($smarty, $template_name, $cache_id, $compile_id, $exp_time); } } \ No newline at end of file diff --git a/libs/sysplugins/smarty_internal_method_clearcompiledtemplate.php b/libs/sysplugins/smarty_internal_method_clearcompiledtemplate.php index f07efafe..4a151575 100644 --- a/libs/sysplugins/smarty_internal_method_clearcompiledtemplate.php +++ b/libs/sysplugins/smarty_internal_method_clearcompiledtemplate.php @@ -33,6 +33,8 @@ class Smarty_Internal_Method_ClearCompiledTemplate */ public function clearCompiledTemplate(Smarty $smarty, $resource_name = null, $compile_id = null, $exp_time = null) { + // clear template objects cache + $smarty->_clearTemplateCache(); $_compile_dir = $smarty->getCompileDir(); if ($_compile_dir == '/') { //We should never want to delete this! @@ -114,9 +116,6 @@ class Smarty_Internal_Method_ClearCompiledTemplate } } } - // clear template objects cache - $smarty->_cache['isCached'] = array(); - $smarty->_cache['tplObjects'] = array(); return $_count; } } \ No newline at end of file