- bugfix a call to clearAllCache() and other should clear all internal template object caches (forum topic 25828)

This commit is contained in:
uwetews
2015-12-15 03:37:13 +01:00
parent 80f872ac06
commit 017120c1ef
7 changed files with 12 additions and 36 deletions

View File

@@ -1,6 +1,7 @@
 ===== 3.1.29-dev ===== (xx.xx.2015)
15.12.2015
- bugfix {$smarty.cookies.foo} did return the $_COOKIE array not the 'foo' value https://github.com/smarty-php/smarty/issues/122
- bugfix a call to clearAllCache() and other should clear all internal template object caches (forum topic 25828)
14.12.2015
- bugfix {$smarty.config.foo} broken in 3.1.28 https://github.com/smarty-php/smarty/issues/120

View File

@@ -118,7 +118,7 @@ class Smarty extends Smarty_Internal_TemplateBase
/**
* smarty version
*/
const SMARTY_VERSION = '3.1.29-dev/4';
const SMARTY_VERSION = '3.1.29-dev/5';
/**
* define variable scopes

View File

@@ -215,12 +215,9 @@ abstract class Smarty_CacheResource
*/
public function invalidLoadedCache(Smarty $smarty)
{
if (isset($smarty->_cache['template_objects'])) {
foreach ($smarty->_cache['template_objects'] as $key => $tpl) {
if (isset($tpl->cached)) {
unset ($smarty->_cache['template_objects'][$key]);
}
}
$smarty->_cache['isCached'] = array();
if (isset($smarty->ext->_subtemplate)) {
$smarty->ext->_subtemplate->tplObjects = array();
}
}
}

View File

@@ -114,14 +114,6 @@ 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) {
unset($smarty->_cache['template_objects'][$key]);
}
}
}
$_count += @unlink((string) $_file) ? 1 : 0;
if (function_exists('opcache_invalidate')) {
opcache_invalidate((string) $_file);

View File

@@ -34,10 +34,7 @@ class Smarty_Internal_Method_ClearAllCache
{
// load cache resource and call clearAll
$_cache_resource = Smarty_CacheResource::load($smarty, $type);
if ($smarty->caching_type != 'file') {
$_cache_resource->invalidLoadedCache($smarty);
}
return $_cache_resource->clearAll($smarty, $exp_time);
}
}

View File

@@ -37,10 +37,7 @@ class Smarty_Internal_Method_ClearCache
{
// load cache resource and call clear
$_cache_resource = Smarty_CacheResource::load($smarty, $type);
if ($smarty->caching_type != 'file' && !isset($template_name)) {
$_cache_resource->invalidLoadedCache($smarty);
}
return $_cache_resource->clear($smarty, $template_name, $cache_id, $compile_id, $exp_time);
}
}

View File

@@ -107,13 +107,6 @@ class Smarty_Internal_Method_ClearCompiledTemplate
}
if ($unlink && @unlink($_filepath)) {
if (isset($smarty->_cache['template_objects'])) {
foreach ($smarty->_cache['template_objects'] as $key => $tpl) {
if (isset($tpl->compiled) && $tpl->compiled->filepath == $_filepath) {
unset($smarty->_cache['template_objects'][$key]);
}
}
}
$_count ++;
if (function_exists('opcache_invalidate')) {
opcache_invalidate($_filepath);
@@ -121,11 +114,10 @@ class Smarty_Internal_Method_ClearCompiledTemplate
}
}
}
// clear compiled cache
if (!isset($resource_name) && isset($smarty->_cache['source_objects'])) {
foreach ($smarty->_cache['source_objects'] as $source) {
$source->compileds = array();
}
// clear template objects cache
$smarty->_cache['isCached'] = array();
if (isset($smarty->ext->_subtemplate)) {
$smarty->ext->_subtemplate->tplObjects = array();
}
return $_count;
}