From 786d110c89e4be64cbbf8ddb358d77e7875e2218 Mon Sep 17 00:00:00 2001 From: messju Date: Fri, 22 Aug 2003 14:02:15 +0000 Subject: [PATCH] discard $_cache_info when the cache should be regenerated --- libs/core/core.read_cache_file.php | 45 +++++++++++++++--------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/libs/core/core.read_cache_file.php b/libs/core/core.read_cache_file.php index b4c02921..29e5930f 100644 --- a/libs/core/core.read_cache_file.php +++ b/libs/core/core.read_cache_file.php @@ -51,47 +51,45 @@ 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'])) { - // cache expired, regenerate - return false; + 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)) { - // cache expired, regenerate - return false; + 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['resource_name'] = $_template_dep; - $smarty->_fetch_resource_info($_params); - if ($smarty->_cache_info['timestamp'] < $_params['resource_timestamp']) { + $_params = array('get_source' => false, 'quiet'=>true); + foreach (array_keys($_cache_info['template']) as $_template_dep) { + $_params['resource_name'] = $_template_dep; + 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']) { - // config file has changed, regenerate cache - return false; - } + if (!$smarty->_fetch_resource_info($_params) || $_cache_info['timestamp'] < $_params['resource_timestamp']) { + // config file has changed, regenerate cache + return false; + } } } } - 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; }