diff --git a/NEW_FEATURES.txt b/NEW_FEATURES.txt index b88a3319..67d391a5 100644 --- a/NEW_FEATURES.txt +++ b/NEW_FEATURES.txt @@ -4,6 +4,11 @@ This file contains a brief description of new features which have been added to Smarty 3.1.28 + OPCACHE + ======= + Smarty does now invalidate automatically updated and cleared compiled or cached template files in OPCACHE. + Correct operation is no longer dependent on OPCACHE configuration settings. + Template inheritance ==================== Template inheritance is now processed in run time. @@ -117,7 +122,7 @@ Smarty 3.1.22 Smarty::DEBUG_INDIVIDUAL have been introduced for setting the $debugging property. - Smarty::DEBUG_INDIVIDUAL will create for each display() and fetch() call an individual gebug window. + Smarty::DEBUG_INDIVIDUAL will create for each display() and fetch() call an individual debug window. . \ No newline at end of file diff --git a/change_log.txt b/change_log.txt index 7d134965..17652fc2 100644 --- a/change_log.txt +++ b/change_log.txt @@ -4,6 +4,7 @@ - optimize subtemplate handling - update template inheritance processing - move code of {call} processing back into Smarty_Internal_Template class + - improvement invalidate OPCACHE for cleared compiled and cached template files (forum topic 25557) 30.08.2015 - size optimization move some runtime functions into extension diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index 12c000bc..586d1ed6 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -119,7 +119,7 @@ class Smarty extends Smarty_Internal_TemplateBase /** * smarty version */ - const SMARTY_VERSION = '3.1.28-dev/58'; + const SMARTY_VERSION = '3.1.28-dev/59'; /** * define variable scopes diff --git a/libs/sysplugins/smarty_internal_extension_clear.php b/libs/sysplugins/smarty_internal_extension_clear.php index 0d40d487..c595214d 100644 --- a/libs/sysplugins/smarty_internal_extension_clear.php +++ b/libs/sysplugins/smarty_internal_extension_clear.php @@ -82,13 +82,16 @@ class Smarty_Internal_Extension_Clear } } // check compile id - if (isset($_compile_id) && (!isset($_parts[$_parts_count - 2 - $_compile_id_offset]) || $_parts[$_parts_count - 2 - $_compile_id_offset] != $_compile_id)) { + if (isset($_compile_id) && (!isset($_parts[$_parts_count - 2 - $_compile_id_offset]) || + $_parts[$_parts_count - 2 - $_compile_id_offset] != $_compile_id) + ) { continue; } // check cache id if (isset($_cache_id)) { // count of cache id parts - $_parts_count = (isset($_compile_id)) ? $_parts_count - 2 - $_compile_id_offset : $_parts_count - 1 - $_compile_id_offset; + $_parts_count = (isset($_compile_id)) ? $_parts_count - 2 - $_compile_id_offset : + $_parts_count - 1 - $_compile_id_offset; if ($_parts_count < $_cache_id_parts_count) { continue; } @@ -114,12 +117,15 @@ class Smarty_Internal_Extension_Clear // remove from template cache if (isset($smarty->_cache['template_objects'])) { foreach ($smarty->_cache['template_objects'] as $key => $tpl) { - if (isset($tpl->cached) && $tpl->cached->filepath == (string)$_file) { + if (isset($tpl->cached) && $tpl->cached->filepath == (string) $_file) { unset($smarty->_cache['template_objects'][$key]); } } } $_count += @unlink((string) $_file) ? 1 : 0; + if (function_exists('opcache_invalidate')) { + opcache_invalidate((string) $_file); + } } } } diff --git a/libs/sysplugins/smarty_internal_method_clearcompiledtemplate.php b/libs/sysplugins/smarty_internal_method_clearcompiledtemplate.php index 9942c982..ae100323 100644 --- a/libs/sysplugins/smarty_internal_method_clearcompiledtemplate.php +++ b/libs/sysplugins/smarty_internal_method_clearcompiledtemplate.php @@ -91,10 +91,11 @@ class Smarty_Internal_Method_ClearCompiledTemplate 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)) + 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) { @@ -114,6 +115,9 @@ class Smarty_Internal_Method_ClearCompiledTemplate } } $_count ++; + if (function_exists('opcache_invalidate')) { + opcache_invalidate($_filepath); + } } } }