From 8cffee84267ee9bb1fed16424ac640033a54c0c7 Mon Sep 17 00:00:00 2001 From: Uwe Tews Date: Thu, 6 Aug 2015 19:02:30 +0200 Subject: [PATCH] invalidate compiled resource cache --- ...marty_internal_extension_clearcompiled.php | 24 +++++++++++-------- libs/sysplugins/smarty_template_compiled.php | 5 ++-- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/libs/sysplugins/smarty_internal_extension_clearcompiled.php b/libs/sysplugins/smarty_internal_extension_clearcompiled.php index 9f6b3e57..9ec27634 100644 --- a/libs/sysplugins/smarty_internal_extension_clearcompiled.php +++ b/libs/sysplugins/smarty_internal_extension_clearcompiled.php @@ -34,8 +34,9 @@ class Smarty_Internal_Extension_ClearCompiled $smarty->caching = false; $tpl = new $smarty->template_class($resource_name, $smarty); $smarty->caching = $_save_stat; - $tpl->loadSource(); // have the template registered before unset() if ($tpl->source->exists) { + // remove from compileds cache + $tpl->source->compileds = array(); // remove from template cache $_templateId = $tpl->getTemplateId($resource_name); if (isset($smarty->template_objects[$_templateId])) { @@ -81,12 +82,13 @@ class Smarty_Internal_Extension_ClearCompiled } } else { $unlink = false; - if ((!isset($_compile_id) || (isset($_filepath[$_compile_id_part_length]) && $a = !strncmp($_filepath, $_compile_id_part, $_compile_id_part_length))) - && (!isset($resource_name) - || (isset($_filepath[$_resource_part_1_length]) - && substr_compare($_filepath, $_resource_part_1, - $_resource_part_1_length, $_resource_part_1_length) == 0) - || (isset($_filepath[$_resource_part_2_length]) - && substr_compare($_filepath, $_resource_part_2, - $_resource_part_2_length, $_resource_part_2_length) == 0)) + if ((!isset($_compile_id) || (isset($_filepath[$_compile_id_part_length]) && + $a = !strncmp($_filepath, $_compile_id_part, $_compile_id_part_length))) && + (!isset($resource_name) || (isset($_filepath[$_resource_part_1_length]) && + substr_compare($_filepath, $_resource_part_1, - $_resource_part_1_length, $_resource_part_1_length) == + 0) || (isset($_filepath[$_resource_part_2_length]) && + substr_compare($_filepath, $_resource_part_2, - $_resource_part_2_length, $_resource_part_2_length) == + 0)) ) { if (isset($exp_time)) { if (time() - @filemtime($_filepath) >= $exp_time) { @@ -103,9 +105,11 @@ class Smarty_Internal_Extension_ClearCompiled } } // clear compiled cache - Smarty_Resource::$sources = array(); - Smarty_Resource::$compileds = array(); - + if (!isset($resource_name)) { + foreach ($smarty->source_objects as $source) { + $source->compileds = array(); + } + } return $_count; } } \ No newline at end of file diff --git a/libs/sysplugins/smarty_template_compiled.php b/libs/sysplugins/smarty_template_compiled.php index f6e95054..9d5ee43a 100644 --- a/libs/sysplugins/smarty_template_compiled.php +++ b/libs/sysplugins/smarty_template_compiled.php @@ -70,9 +70,6 @@ class Smarty_Template_Compiled static function load($_template) { $smarty = $_template->smarty; - if (!isset($_template->source)) { - $_template->loadSource(); - } $source = $_template->source; // check runtime cache if (!$source->recompiled && $smarty->resource_caching) { @@ -162,6 +159,7 @@ class Smarty_Template_Compiled ($_template->smarty->compile_check && $_template->source->getTimeStamp() > $_template->compiled->getTimeStamp()) ) { + $_template->source->compileds = array(); $this->compileTemplateSource($_template); $compileCheck = $_template->smarty->compile_check; $_template->smarty->compile_check = false; @@ -186,6 +184,7 @@ class Smarty_Template_Compiled } else { include($_template->compiled->filepath); if ($_template->mustCompile) { + $_template->source->compileds = array(); $this->compileTemplateSource($_template); $compileCheck = $_template->smarty->compile_check; $_template->smarty->compile_check = false;