mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-05 19:04:27 +02:00
fixed clear_all_cache bugs
This commit is contained in:
@@ -56,7 +56,7 @@ class Smarty
|
||||
// compiling directives. If a cached version
|
||||
// is available, that will be used regardless
|
||||
// of compile settings.
|
||||
var $caching = true; // whether to use caching or not. true/false
|
||||
var $caching = false; // whether to use caching or not. true/false
|
||||
var $cache_lifetime = 3600; // number of seconds cached content will persist.
|
||||
// 0 = never expires. default is one hour (3600)
|
||||
|
||||
@@ -168,6 +168,27 @@ class Smarty
|
||||
unset($this->_tpl_vars[$tpl_var]);
|
||||
}
|
||||
|
||||
/*======================================================================*\
|
||||
Function: clear_all_cache()
|
||||
Purpose: clear all the cached template files.
|
||||
\*======================================================================*/
|
||||
|
||||
function clear_all_cache()
|
||||
{
|
||||
if(is_dir($this->cache_dir))
|
||||
$dir_handle = opendir($this->cache_dir);
|
||||
else
|
||||
return false;
|
||||
|
||||
while($curr_file = readdir($dir_handle)) {
|
||||
if ($curr_file == '.' || $curr_file == '..')
|
||||
continue;
|
||||
if(is_file($this->cache_dir."/".$curr_file) && substr($curr_file,-6) == '.cache')
|
||||
unlink($this->cache_dir."/".$curr_file);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/*======================================================================*\
|
||||
Function: clear_all_assign()
|
||||
Purpose: clear all the assigned template variables.
|
||||
@@ -254,23 +275,7 @@ class Smarty
|
||||
return;
|
||||
} else
|
||||
return $results;
|
||||
}
|
||||
|
||||
/*======================================================================*\
|
||||
Function: clear_all_cache()
|
||||
Purpose: clear all the cached template files.
|
||||
\*======================================================================*/
|
||||
|
||||
function clear_all_cache()
|
||||
{
|
||||
while($curr_file = readdir($this->cache_dir)) {
|
||||
if ($curr_file == '.' || $curr_file == '..')
|
||||
continue;
|
||||
if(substr($curr_file,-6) == '.cache')
|
||||
unlink($curr_file);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*======================================================================*\
|
||||
Function: compile()
|
||||
|
@@ -56,7 +56,7 @@ class Smarty
|
||||
// compiling directives. If a cached version
|
||||
// is available, that will be used regardless
|
||||
// of compile settings.
|
||||
var $caching = true; // whether to use caching or not. true/false
|
||||
var $caching = false; // whether to use caching or not. true/false
|
||||
var $cache_lifetime = 3600; // number of seconds cached content will persist.
|
||||
// 0 = never expires. default is one hour (3600)
|
||||
|
||||
@@ -168,6 +168,27 @@ class Smarty
|
||||
unset($this->_tpl_vars[$tpl_var]);
|
||||
}
|
||||
|
||||
/*======================================================================*\
|
||||
Function: clear_all_cache()
|
||||
Purpose: clear all the cached template files.
|
||||
\*======================================================================*/
|
||||
|
||||
function clear_all_cache()
|
||||
{
|
||||
if(is_dir($this->cache_dir))
|
||||
$dir_handle = opendir($this->cache_dir);
|
||||
else
|
||||
return false;
|
||||
|
||||
while($curr_file = readdir($dir_handle)) {
|
||||
if ($curr_file == '.' || $curr_file == '..')
|
||||
continue;
|
||||
if(is_file($this->cache_dir."/".$curr_file) && substr($curr_file,-6) == '.cache')
|
||||
unlink($this->cache_dir."/".$curr_file);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/*======================================================================*\
|
||||
Function: clear_all_assign()
|
||||
Purpose: clear all the assigned template variables.
|
||||
@@ -254,23 +275,7 @@ class Smarty
|
||||
return;
|
||||
} else
|
||||
return $results;
|
||||
}
|
||||
|
||||
/*======================================================================*\
|
||||
Function: clear_all_cache()
|
||||
Purpose: clear all the cached template files.
|
||||
\*======================================================================*/
|
||||
|
||||
function clear_all_cache()
|
||||
{
|
||||
while($curr_file = readdir($this->cache_dir)) {
|
||||
if ($curr_file == '.' || $curr_file == '..')
|
||||
continue;
|
||||
if(substr($curr_file,-6) == '.cache')
|
||||
unlink($curr_file);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*======================================================================*\
|
||||
Function: compile()
|
||||
|
Reference in New Issue
Block a user