mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 18:34:27 +02:00
- improvement invalidate OPCACHE for cleared compiled and cached template files (forum topic 25557)
This commit is contained in:
@@ -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.
|
||||
|
||||
.
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user