From 297f47a15ad95340d8663e54caa6328aa81e1333 Mon Sep 17 00:00:00 2001 From: uwetews Date: Thu, 24 Dec 2015 02:29:21 +0100 Subject: [PATCH] - new feature Compiler does now observe the template_dir setting and will create separate compiled files if required --- NEW_FEATURES.txt | 6 ++++++ change_log.txt | 3 +++ demo/plugins/resource.extendsall.php | 4 ++-- libs/Smarty.class.php | 2 +- libs/sysplugins/smarty_internal_resource_extends.php | 2 +- libs/sysplugins/smarty_internal_resource_file.php | 2 +- libs/sysplugins/smarty_internal_resource_registered.php | 2 +- libs/sysplugins/smarty_internal_resource_string.php | 2 +- 8 files changed, 16 insertions(+), 7 deletions(-) diff --git a/NEW_FEATURES.txt b/NEW_FEATURES.txt index 36741c14..9a33dd75 100644 --- a/NEW_FEATURES.txt +++ b/NEW_FEATURES.txt @@ -8,6 +8,12 @@ Smarty 3.1.30 ======= Caching does now observe the template_dir setting and will create separate cache files if required + Compiled Templates + ================== + The template_dir setting is now encoded in the uid of the file name. + The content of the compiled template may depend on the template_dir search order + {include .... inline} is used or $smarty->merge_compiled_includes is enabled + Smarty 3.1.28 OPCACHE diff --git a/change_log.txt b/change_log.txt index bf78d77d..fd806f9e 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,4 +1,7 @@  ===== 3.1.30-dev ===== (xx.xx.xx) + 24.12.2015 + - new feature Compiler does now observe the template_dir setting and will create separate compiled files if required + 23.12.2015 - optimization move internal method decodeProperties back into template object - optimization move subtemplate processing back into template object diff --git a/demo/plugins/resource.extendsall.php b/demo/plugins/resource.extendsall.php index 5f55d44b..a5ee432d 100644 --- a/demo/plugins/resource.extendsall.php +++ b/demo/plugins/resource.extendsall.php @@ -23,7 +23,7 @@ class Smarty_Resource_Extendsall extends Smarty_Internal_Resource_Extends $uid = ''; $sources = array(); $timestamp = 0; - foreach ($_template->smarty->getTemplateDir() as $key => $directory) { + foreach ($source->smarty->getTemplateDir() as $key => $directory) { try { $s = Smarty_Resource::source(null, $source->smarty, 'file:' . '[' . $key . ']' . $source->name); if (!$s->exists) { @@ -46,7 +46,7 @@ class Smarty_Resource_Extendsall extends Smarty_Internal_Resource_Extends $s = current($sources); $source->components = $sources; $source->filepath = $s->filepath; - $source->uid = sha1($uid . $_template->smarty->_joined_template_dir); + $source->uid = sha1($uid . $source->smarty->_joined_template_dir); $source->exists = true; $source->timestamp = $timestamp; } diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index 0670ed97..602ff5a4 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -118,7 +118,7 @@ class Smarty extends Smarty_Internal_TemplateBase /** * smarty version */ - const SMARTY_VERSION = '3.1.30-dev/7'; + const SMARTY_VERSION = '3.1.30-dev/8'; /** * define variable scopes diff --git a/libs/sysplugins/smarty_internal_resource_extends.php b/libs/sysplugins/smarty_internal_resource_extends.php index 3d687dca..4a712e52 100644 --- a/libs/sysplugins/smarty_internal_resource_extends.php +++ b/libs/sysplugins/smarty_internal_resource_extends.php @@ -52,7 +52,7 @@ class Smarty_Internal_Resource_Extends extends Smarty_Resource } $source->components = $sources; $source->filepath = $_s->filepath; - $source->uid = sha1($uid); + $source->uid = sha1($uid . $source->smarty->_joined_template_dir); $source->exists = $exists; if ($_template) { $source->timestamp = $_s->timestamp; diff --git a/libs/sysplugins/smarty_internal_resource_file.php b/libs/sysplugins/smarty_internal_resource_file.php index b15e3cc6..8897a1f1 100644 --- a/libs/sysplugins/smarty_internal_resource_file.php +++ b/libs/sysplugins/smarty_internal_resource_file.php @@ -123,7 +123,7 @@ class Smarty_Internal_Resource_File extends Smarty_Resource $source->smarty->security_policy->isTrustedResourceDir($source->filepath, $source->isConfig); } $source->exists = true; - $source->uid = sha1($source->filepath); + $source->uid = sha1($source->filepath . ($source->isConfig ? $source->smarty->_joined_config_dir : $source->smarty->_joined_template_dir)); if ($source->smarty->compile_check == 1) { $source->timestamp = filemtime($source->filepath); } diff --git a/libs/sysplugins/smarty_internal_resource_registered.php b/libs/sysplugins/smarty_internal_resource_registered.php index 69b396b6..5f6ebc29 100644 --- a/libs/sysplugins/smarty_internal_resource_registered.php +++ b/libs/sysplugins/smarty_internal_resource_registered.php @@ -29,7 +29,7 @@ class Smarty_Internal_Resource_Registered extends Smarty_Resource public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template = null) { $source->filepath = $source->type . ':' . $source->name; - $source->uid = sha1($source->filepath); + $source->uid = sha1($source->filepath . $source->smarty->_joined_template_dir); if ($source->smarty->compile_check) { $source->timestamp = $this->getTemplateTimestamp($source); $source->exists = !!$source->timestamp; diff --git a/libs/sysplugins/smarty_internal_resource_string.php b/libs/sysplugins/smarty_internal_resource_string.php index 75e99e6f..37e66be3 100644 --- a/libs/sysplugins/smarty_internal_resource_string.php +++ b/libs/sysplugins/smarty_internal_resource_string.php @@ -28,7 +28,7 @@ class Smarty_Internal_Resource_String extends Smarty_Resource */ public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template = null) { - $source->uid = $source->filepath = sha1($source->name); + $source->uid = $source->filepath = sha1($source->name . $source->smarty->_joined_template_dir); $source->timestamp = 0; $source->exists = true; }