From 24141e81dd72a8890a77e6d4596fee40d0d446c4 Mon Sep 17 00:00:00 2001 From: "Uwe.Tews" Date: Mon, 8 Feb 2010 21:04:43 +0000 Subject: [PATCH] =?UTF-8?q?-=20bugfix=20=20use=20template=20fullpath=20at?= =?UTF-8?q?=20=C2=A7smarty->cache->clear(...),=20$smarty->clear=5Fcache(..?= =?UTF-8?q?..)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- change_log.txt | 1 + .../smarty_internal_cacheresource_file.php | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/change_log.txt b/change_log.txt index ee5f8406..00900040 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,4 +1,5 @@ 08/02/2010 +- bugfix use template fullpath at §smarty->cache->clear(...), $smarty->clear_cache(....) - bugfix of cache filename on extended templates when force_compile=true 07/02/2010 diff --git a/libs/sysplugins/smarty_internal_cacheresource_file.php b/libs/sysplugins/smarty_internal_cacheresource_file.php index c2614c3c..445d9deb 100644 --- a/libs/sysplugins/smarty_internal_cacheresource_file.php +++ b/libs/sysplugins/smarty_internal_cacheresource_file.php @@ -29,7 +29,7 @@ class Smarty_Internal_CacheResource_File { { $_source_file_path = str_replace(':', '.', $_template->getTemplateFilepath()); $_cache_id = isset($_template->cache_id) ? preg_replace('![^\w\|]+!', '_', $_template->cache_id) : null; - $_compile_id = isset($_template->compile_id) ? preg_replace('![^\w\|]+!', '_', $_template->compile_id) : null; + $_compile_id = isset($_template->compile_id) ? preg_replace('![^\w\|]+!', '_', $_template->compile_id) : null; $_filepath = $_template->templateUid; // if use_sub_dirs, break file into directories if ($this->smarty->use_sub_dirs) { @@ -130,6 +130,14 @@ class Smarty_Internal_CacheResource_File { $_cache_id_parts = explode('|', $_cache_id); $_cache_id_parts_count = count($_cache_id_parts); } + if (isset($resource_name)) { + $tpl = $this->smarty->createTemplate($resource_name); + if ($tpl->isExisting()) { + $_resourcename_parts = basename(str_replace('^','/',$tpl->getCachedFilepath())); + } else { + return 0; + } + } $_count = 0; $_cacheDirs = new RecursiveDirectoryIterator($_dir); $_cache = new RecursiveIteratorIterator($_cacheDirs, RecursiveIteratorIterator::CHILD_FIRST); @@ -146,15 +154,10 @@ class Smarty_Internal_CacheResource_File { $_parts_count = count($_parts); // check name if (isset($resource_name)) { - $_filename_parts = explode('.', $_parts[$_parts_count-1]); - $_resourcename_parts = explode('.', $resource_name . '.php'); - if (count($_filename_parts)-1 != count($_resourcename_parts)) { + if ($_parts[$_parts_count-1] != $_resourcename_parts) { continue; } - for ($i = 0; $i < count($_resourcename_parts); $i++) { - if ($_filename_parts[$i + 1] != $_resourcename_parts[$i]) continue 2; - } - } + } // check compile id if (isset($_compile_id) && $_parts[$_parts_count-2 - $_compile_id_offset] != $_compile_id) { continue;