mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 18:34:27 +02:00
discard $_cache_info when the cache should be regenerated
This commit is contained in:
@@ -51,39 +51,37 @@ function smarty_core_read_cache_file(&$params, &$smarty)
|
||||
$cache_split = explode("\n", $params['results'], 2);
|
||||
$cache_header = $cache_split[0];
|
||||
|
||||
$smarty->_cache_info = unserialize($cache_header);
|
||||
$_cache_info = unserialize($cache_header);
|
||||
|
||||
if ($smarty->caching == 2 && isset ($smarty->_cache_info['expires'])){
|
||||
if ($smarty->caching == 2 && isset ($_cache_info['expires'])){
|
||||
// caching by expiration time
|
||||
if ($smarty->_cache_info['expires'] > -1 && (time() > $smarty->_cache_info['expires'])) {
|
||||
if ($_cache_info['expires'] > -1 && (time() > $_cache_info['expires'])) {
|
||||
// cache expired, regenerate
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
// caching by lifetime
|
||||
if ($smarty->cache_lifetime > -1 && (time() - $smarty->_cache_info['timestamp'] > $smarty->cache_lifetime)) {
|
||||
if ($smarty->cache_lifetime > -1 && (time() - $_cache_info['timestamp'] > $smarty->cache_lifetime)) {
|
||||
// cache expired, regenerate
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if ($smarty->compile_check) {
|
||||
$_params = array('get_source' => false);
|
||||
foreach (array_keys($smarty->_cache_info['template']) as $_template_dep) {
|
||||
$_params = array('get_source' => false, 'quiet'=>true);
|
||||
foreach (array_keys($_cache_info['template']) as $_template_dep) {
|
||||
$_params['resource_name'] = $_template_dep;
|
||||
$smarty->_fetch_resource_info($_params);
|
||||
if ($smarty->_cache_info['timestamp'] < $_params['resource_timestamp']) {
|
||||
if (!$smarty->_fetch_resource_info($_params) || $_cache_info['timestamp'] < $_params['resource_timestamp']) {
|
||||
// template file has changed, regenerate cache
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($smarty->_cache_info['config'])) {
|
||||
$_params = array('resource_base_path' => $smarty->config_dir, 'get_source' => false);
|
||||
foreach (array_keys($smarty->_cache_info['config']) as $_config_dep) {
|
||||
if (isset($_cache_info['config'])) {
|
||||
$_params = array('resource_base_path' => $smarty->config_dir, 'get_source' => false, 'quiet'=>true);
|
||||
foreach (array_keys($_cache_info['config']) as $_config_dep) {
|
||||
$_params['resource_name'] = $_config_dep;
|
||||
$smarty->_fetch_resource_info($_params);
|
||||
if ($smarty->_cache_info['timestamp'] < $_params['resource_timestamp']) {
|
||||
if (!$smarty->_fetch_resource_info($_params) || $_cache_info['timestamp'] < $_params['resource_timestamp']) {
|
||||
// config file has changed, regenerate cache
|
||||
return false;
|
||||
}
|
||||
@@ -91,7 +89,7 @@ function smarty_core_read_cache_file(&$params, &$smarty)
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($smarty->_cache_info['cache_serials'] as $_include_file_path=>$_cache_serial) {
|
||||
foreach ($_cache_info['cache_serials'] as $_include_file_path=>$_cache_serial) {
|
||||
if (empty($smarty->_cache_serials[$_include_file_path])) {
|
||||
$smarty->_include($_include_file_path, true);
|
||||
}
|
||||
@@ -102,8 +100,9 @@ function smarty_core_read_cache_file(&$params, &$smarty)
|
||||
}
|
||||
}
|
||||
$params['results'] = $cache_split[1];
|
||||
$content_cache[$params['tpl_file'].','.$params['cache_id'].','.$params['compile_id']] = array($params['results'], $smarty->_cache_info);
|
||||
$content_cache[$params['tpl_file'].','.$params['cache_id'].','.$params['compile_id']] = array($params['results'], $_cache_info);
|
||||
|
||||
$smarty->_cache_info = $_cache_info;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user