- new feature Caching does now observe the template_dir setting and will create separate cache files if required

This commit is contained in:
uwetews
2015-12-23 04:35:48 +01:00
parent db2cace210
commit 5c377637e1
5 changed files with 11 additions and 4 deletions

View File

@@ -2,6 +2,12 @@
This file contains a brief description of new features which have been added to Smarty 3.1 This file contains a brief description of new features which have been added to Smarty 3.1
Smarty 3.1.30
Caching
=======
Caching does now observe the template_dir setting and will create separate cache files if required
Smarty 3.1.28 Smarty 3.1.28
OPCACHE OPCACHE

View File

@@ -2,6 +2,7 @@
23.12.2015 23.12.2015
- optimization move internal method decodeProperties back into template object - optimization move internal method decodeProperties back into template object
- optimization move subtemplate processing back into template object - optimization move subtemplate processing back into template object
- new feature Caching does now observe the template_dir setting and will create separate cache files if required
22.12.2015 22.12.2015
- change $xxx_dir properties from private to protected in case Smarty class gets extended - change $xxx_dir properties from private to protected in case Smarty class gets extended

View File

@@ -84,7 +84,7 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
{ {
$_cache_id = isset($cached->cache_id) ? preg_replace('![^\w\|]+!', '_', $cached->cache_id) : null; $_cache_id = isset($cached->cache_id) ? preg_replace('![^\w\|]+!', '_', $cached->cache_id) : null;
$_compile_id = isset($cached->compile_id) ? preg_replace('![^\w]+!', '_', $cached->compile_id) : null; $_compile_id = isset($cached->compile_id) ? preg_replace('![^\w]+!', '_', $cached->compile_id) : null;
$path = $cached->source->filepath . $_cache_id . $_compile_id; $path = $cached->source->filepath . $_template->smarty->_joined_template_dir. $_cache_id . $_compile_id;
$cached->filepath = sha1($path); $cached->filepath = sha1($path);
if ($_template->smarty->cache_locking) { if ($_template->smarty->cache_locking) {
$cached->lock_id = sha1('lock.' . $path); $cached->lock_id = sha1('lock.' . $path);

View File

@@ -54,7 +54,7 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
*/ */
public function populate(Smarty_Template_Cached $cached, Smarty_Internal_Template $_template) public function populate(Smarty_Template_Cached $cached, Smarty_Internal_Template $_template)
{ {
$cached->filepath = $_template->source->uid . '#' . $this->sanitize($cached->source->resource) . '#' . $cached->filepath = sha1($_template->source->uid . $_template->smarty->_joined_template_dir) . '#' . $this->sanitize($cached->source->resource) . '#' .
$this->sanitize($cached->cache_id) . '#' . $this->sanitize($cached->compile_id); $this->sanitize($cached->cache_id) . '#' . $this->sanitize($cached->compile_id);
$this->populateTimestamp($cached); $this->populateTimestamp($cached);

View File

@@ -30,7 +30,7 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource
$_source_file_path = str_replace(':', '.', $_template->source->filepath); $_source_file_path = str_replace(':', '.', $_template->source->filepath);
$_cache_id = isset($_template->cache_id) ? preg_replace('![^\w\|]+!', '_', $_template->cache_id) : null; $_cache_id = isset($_template->cache_id) ? preg_replace('![^\w\|]+!', '_', $_template->cache_id) : null;
$_compile_id = isset($_template->compile_id) ? preg_replace('![^\w]+!', '_', $_template->compile_id) : null; $_compile_id = isset($_template->compile_id) ? preg_replace('![^\w]+!', '_', $_template->compile_id) : null;
$_filepath = $_template->source->uid; $_filepath = sha1($_template->source->uid . $_template->smarty->_joined_template_dir);
// if use_sub_dirs, break file into directories // if use_sub_dirs, break file into directories
if ($_template->smarty->use_sub_dirs) { if ($_template->smarty->use_sub_dirs) {
$_filepath = substr($_filepath, 0, 2) . DS . substr($_filepath, 2, 2) . DS . substr($_filepath, 4, 2) . DS . $_filepath = substr($_filepath, 0, 2) . DS . substr($_filepath, 2, 2) . DS . substr($_filepath, 4, 2) . DS .