From 63b1d343b86b31c78e44b590b7e45ac7a7485093 Mon Sep 17 00:00:00 2001 From: Uwe Tews Date: Wed, 27 May 2015 22:24:24 +0200 Subject: [PATCH] - bugfix {include} with variable file name must not create by default individual cache file (since 3.1.22) https://github.com/smarty-php/smarty/issues/43 --- change_log.txt | 3 ++ libs/Smarty.class.php | 2 +- .../smarty_internal_compile_include.php | 38 +++++++++---------- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/change_log.txt b/change_log.txt index ec1a126e..f657da6f 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,4 +1,7 @@  ===== 3.1.25-dev===== (xx.xx.2015) + 27.05.2015 + - bugfix {include} with variable file name must not create by default individual cache file (since 3.1.22) https://github.com/smarty-php/smarty/issues/43 + 24.05.2015 - bugfix if condition string 'neq' broken due to a typo https://github.com/smarty-php/smarty/issues/42 diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index 37d8005b..c5c3def3 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -111,7 +111,7 @@ class Smarty extends Smarty_Internal_TemplateBase /** * smarty version */ - const SMARTY_VERSION = '3.1.25-dev/1'; + const SMARTY_VERSION = '3.1.25-dev/2'; /** * define variable scopes diff --git a/libs/sysplugins/smarty_internal_compile_include.php b/libs/sysplugins/smarty_internal_compile_include.php index 9c7aea0d..b0720a29 100644 --- a/libs/sysplugins/smarty_internal_compile_include.php +++ b/libs/sysplugins/smarty_internal_compile_include.php @@ -101,31 +101,29 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase // flag if included template code should be merged into caller $merge_compiled_includes = ($compiler->smarty->merge_compiled_includes || ($compiler->inheritance && $compiler->smarty->inheritance_merge_compiled_includes) || $_attr['inline'] === true) && !$compiler->template->source->recompiled; - // variable template name ? - if ($compiler->has_variable_string || !((substr_count($include_file, '"') == 2 || substr_count($include_file, "'") == 2)) - || substr_count($include_file, '(') != 0 || substr_count($include_file, '$_smarty_tpl->') != 0 - ) { - $merge_compiled_includes = false; - if ($compiler->template->caching) { - // must use individual cache file - $_attr['caching'] = 1; - } - if ($compiler->inheritance && $compiler->smarty->inheritance_merge_compiled_includes && $_attr['inline'] !== true) { - $compiler->trigger_template_error(' variable template file names not allow within {block} tags'); - } - } - // variable compile_id? - if (isset($_attr['compile_id'])) { - if (!((substr_count($_attr['compile_id'], '"') == 2 || substr_count($_attr['compile_id'], "'") == 2 || is_numeric($_attr['compile_id']))) - || substr_count($_attr['compile_id'], '(') != 0 || substr_count($_attr['compile_id'], '$_smarty_tpl->') != 0 - ) { + if ($merge_compiled_includes && $_attr['inline'] !== true) { + // variable template name ? + if ($compiler->has_variable_string || !((substr_count($include_file, '"') == 2 || substr_count($include_file, "'") == 2)) || substr_count($include_file, '(') != 0 || substr_count($include_file, '$_smarty_tpl->') != 0) { $merge_compiled_includes = false; if ($compiler->template->caching) { // must use individual cache file - $_attr['caching'] = 1; + //$_attr['caching'] = 1; } if ($compiler->inheritance && $compiler->smarty->inheritance_merge_compiled_includes && $_attr['inline'] !== true) { - $compiler->trigger_template_error(' variable compile_id not allow within {block} tags'); + $compiler->trigger_template_error(' variable template file names not allow within {block} tags'); + } + } + // variable compile_id? + if (isset($_attr['compile_id'])) { + if (!((substr_count($_attr['compile_id'], '"') == 2 || substr_count($_attr['compile_id'], "'") == 2 || is_numeric($_attr['compile_id']))) || substr_count($_attr['compile_id'], '(') != 0 || substr_count($_attr['compile_id'], '$_smarty_tpl->') != 0) { + $merge_compiled_includes = false; + if ($compiler->template->caching) { + // must use individual cache file + //$_attr['caching'] = 1; + } + if ($compiler->inheritance && $compiler->smarty->inheritance_merge_compiled_includes && $_attr['inline'] !== true) { + $compiler->trigger_template_error(' variable compile_id not allow within {block} tags'); + } } } }