- 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)  ===== 3.1.29-dev ===== (xx.xx.2015)
15.12.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 {$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 14.12.2015
- bugfix {$smarty.config.foo} broken in 3.1.28 https://github.com/smarty-php/smarty/issues/120 - 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 * smarty version
*/ */
const SMARTY_VERSION = '3.1.29-dev/4'; const SMARTY_VERSION = '3.1.29-dev/5';
/** /**
* define variable scopes * define variable scopes

View File

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

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; $_count += @unlink((string) $_file) ? 1 : 0;
if (function_exists('opcache_invalidate')) { if (function_exists('opcache_invalidate')) {
opcache_invalidate((string) $_file); opcache_invalidate((string) $_file);

View File

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

View File

@@ -37,10 +37,7 @@ class Smarty_Internal_Method_ClearCache
{ {
// load cache resource and call clear // load cache resource and call clear
$_cache_resource = Smarty_CacheResource::load($smarty, $type); $_cache_resource = Smarty_CacheResource::load($smarty, $type);
if ($smarty->caching_type != 'file' && !isset($template_name)) { $_cache_resource->invalidLoadedCache($smarty);
$_cache_resource->invalidLoadedCache($smarty);
}
return $_cache_resource->clear($smarty, $template_name, $cache_id, $compile_id, $exp_time); 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 ($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 ++; $_count ++;
if (function_exists('opcache_invalidate')) { if (function_exists('opcache_invalidate')) {
opcache_invalidate($_filepath); opcache_invalidate($_filepath);
@@ -121,11 +114,10 @@ class Smarty_Internal_Method_ClearCompiledTemplate
} }
} }
} }
// clear compiled cache // clear template objects cache
if (!isset($resource_name) && isset($smarty->_cache['source_objects'])) { $smarty->_cache['isCached'] = array();
foreach ($smarty->_cache['source_objects'] as $source) { if (isset($smarty->ext->_subtemplate)) {
$source->compileds = array(); $smarty->ext->_subtemplate->tplObjects = array();
}
} }
return $_count; return $_count;
} }