new _clearTemplateCache() method

This commit is contained in:
uwetews
2015-12-27 03:28:26 +01:00
parent fbf544286a
commit 7e7591f6c0
5 changed files with 12 additions and 16 deletions

View File

@@ -1193,6 +1193,14 @@ class Smarty extends Smarty_Internal_TemplateBase
return $path;
}
/**
* Empty template objects cache
*/
public function _clearTemplateCache() {
$this->_cache['isCached'] = array();
$this->_cache['tplObjects'] = array();
}
/**
* @param boolean $compile_check
*/

View File

@@ -207,15 +207,4 @@ abstract class Smarty_CacheResource
// give up
throw new SmartyException("Unable to load cache resource '{$type}'");
}
/**
* Invalid Loaded Cache Files
*
* @param Smarty $smarty Smarty object
*/
public function invalidLoadedCache(Smarty $smarty)
{
$smarty->_cache['isCached'] = array();
$smarty->_cache['tplObjects'] = array();
}
}

View File

@@ -32,9 +32,9 @@ class Smarty_Internal_Method_ClearAllCache
*/
public function clearAllCache(Smarty $smarty, $exp_time = null, $type = null)
{
$smarty->_clearTemplateCache();
// load cache resource and call clearAll
$_cache_resource = Smarty_CacheResource::load($smarty, $type);
$_cache_resource->invalidLoadedCache($smarty);
return $_cache_resource->clearAll($smarty, $exp_time);
}
}

View File

@@ -35,9 +35,9 @@ class Smarty_Internal_Method_ClearCache
*/
public function clearCache(Smarty $smarty, $template_name, $cache_id = null, $compile_id = null, $exp_time = null, $type = null)
{
$smarty->_clearTemplateCache();
// load cache resource and call clear
$_cache_resource = Smarty_CacheResource::load($smarty, $type);
$_cache_resource->invalidLoadedCache($smarty);
return $_cache_resource->clear($smarty, $template_name, $cache_id, $compile_id, $exp_time);
}
}

View File

@@ -33,6 +33,8 @@ class Smarty_Internal_Method_ClearCompiledTemplate
*/
public function clearCompiledTemplate(Smarty $smarty, $resource_name = null, $compile_id = null, $exp_time = null)
{
// clear template objects cache
$smarty->_clearTemplateCache();
$_compile_dir = $smarty->getCompileDir();
if ($_compile_dir == '/') { //We should never want to delete this!
@@ -114,9 +116,6 @@ class Smarty_Internal_Method_ClearCompiledTemplate
}
}
}
// clear template objects cache
$smarty->_cache['isCached'] = array();
$smarty->_cache['tplObjects'] = array();
return $_count;
}
}