From 797bd37c5f1abdab3147d2eb0d21fb351ac0d3e0 Mon Sep 17 00:00:00 2001 From: "Uwe.Tews@googlemail.com" Date: Wed, 8 Jan 2014 21:05:58 +0000 Subject: [PATCH] - bugfix Smarty_CacheResource_Custom did not handle template resource type specifications on clearCache() calls (Issue 161) --- change_log.txt | 3 ++ .../smarty_cacheresource_custom.php | 28 ++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/change_log.txt b/change_log.txt index 90a598f8..1daa35e9 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,4 +1,7 @@ ===== trunk ===== + 08.01.2014 + - bugfix Smarty_CacheResource_Custom did not handle template resource type specifications on clearCache() calls (Issue 161) + ===== 3.1.16 ===== 15.12.2013 - bugfix {include} with {block} tag handling (forum topic 24599, 24594, 24682) (Issue 161) diff --git a/libs/sysplugins/smarty_cacheresource_custom.php b/libs/sysplugins/smarty_cacheresource_custom.php index a81b545a..f6c9d61d 100644 --- a/libs/sysplugins/smarty_cacheresource_custom.php +++ b/libs/sysplugins/smarty_cacheresource_custom.php @@ -186,8 +186,34 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource public function clear(Smarty $smarty, $resource_name, $cache_id, $compile_id, $exp_time) { $this->cache = array(); + $cache_name = null; - return $this->delete($resource_name, $cache_id, $compile_id, $exp_time); + if (isset($resource_name)) { + $_save_stat = $smarty->caching; + $smarty->caching = true; + $tpl = new $smarty->template_class($resource_name, $smarty); + $smarty->caching = $_save_stat; + + if ($tpl->source->exists) { + $cache_name = $tpl->source->name; + } else { + return 0; + } + // remove from template cache + if ($smarty->allow_ambiguous_resources) { + $_templateId = $tpl->source->unique_resource . $tpl->cache_id . $tpl->compile_id; + } else { + $_templateId = $smarty->joined_template_dir . '#' . $resource_name . $tpl->cache_id . $tpl->compile_id; + } + if (isset($_templateId[150])) { + $_templateId = sha1($_templateId); + } + unset($smarty->template_objects[$_templateId]); + // template object no longer needed + unset($tpl); + } + + return $this->delete($cache_name, $cache_id, $compile_id, $exp_time); } /**