fixed serialization of values containing newlines (like _cache_attrs)

in core_write_cache_file()

bumped version to 2.6.6-dev-3 to indicate that the fileformat of cache
has changed
This commit is contained in:
messju
2005-02-01 10:19:08 +00:00
parent 4fa9c7299f
commit c6827dee8a
3 changed files with 8 additions and 7 deletions

View File

@@ -464,7 +464,7 @@ class Smarty
*
* @var string
*/
var $_version = '2.6.6-dev-2';
var $_version = '2.6.6-dev-3';
/**
* current template inclusion depth

View File

@@ -48,10 +48,11 @@ function smarty_core_read_cache_file(&$params, &$smarty)
return false;
}
$cache_split = explode("\n", $params['results'], 2);
$cache_header = $cache_split[0];
$_cache_info = unserialize($cache_header);
$_contents = $params['results'];
$_info_start = strpos($_contents, "\n") + 1;
$_info_len = (int)substr($_contents, 0, $_info_start - 1);
$_cache_info = unserialize(substr($_contents, $_info_start, $_info_len));
$params['results'] = substr($_contents, $_info_start + $_info_len);
if ($smarty->caching == 2 && isset ($_cache_info['expires'])){
// caching by expiration time
@@ -99,7 +100,6 @@ function smarty_core_read_cache_file(&$params, &$smarty)
return false;
}
}
$params['results'] = $cache_split[1];
$content_cache[$params['tpl_file'].','.$params['cache_id'].','.$params['compile_id']] = array($params['results'], $_cache_info);
$smarty->_cache_info = $_cache_info;

View File

@@ -62,7 +62,8 @@ function smarty_core_write_cache_file($params, &$smarty)
$smarty->_cache_info['cache_serials'] = $smarty->_cache_serials;
// prepend the cache header info into cache file
$params['results'] = serialize($smarty->_cache_info)."\n".$params['results'];
$_cache_info = serialize($smarty->_cache_info);
$params['results'] = strlen($_cache_info) . "\n" . $_cache_info . $params['results'];
if (!empty($smarty->cache_handler_func)) {
// use cache_handler function