From fcf108b33f0ae05fb7687bf5769cf658782e1504 Mon Sep 17 00:00:00 2001 From: Uwe Tews Date: Mon, 20 Nov 2017 11:11:46 +0100 Subject: [PATCH] bugfix variable filter might not have been loaded in cache file for use in nocache sections. --- change_log.txt | 1 + libs/Smarty.class.php | 2 +- ...ernal_compile_private_print_expression.php | 32 ++++++------------- 3 files changed, 11 insertions(+), 24 deletions(-) diff --git a/change_log.txt b/change_log.txt index a158cf09..c3bfd8cf 100644 --- a/change_log.txt +++ b/change_log.txt @@ -2,6 +2,7 @@ 20.11.2017 - bugfix rework of newline spacing between tag code and template text. now again identical with Smarty2 (forum topic 26878) + - bugfix variable filter might not have been loaded in cache file for use in nocache sections. 05.11.2017 - lexer/parser optimization diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index 67d495a5..7d9aa9a1 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -112,7 +112,7 @@ class Smarty extends Smarty_Internal_TemplateBase /** * smarty version */ - const SMARTY_VERSION = '3.1.32-dev-36'; + const SMARTY_VERSION = '3.1.32-dev-37'; /** * define variable scopes */ diff --git a/libs/sysplugins/smarty_internal_compile_private_print_expression.php b/libs/sysplugins/smarty_internal_compile_private_print_expression.php index f1dc0938..2dde6948 100644 --- a/libs/sysplugins/smarty_internal_compile_private_print_expression.php +++ b/libs/sysplugins/smarty_internal_compile_private_print_expression.php @@ -100,18 +100,18 @@ class Smarty_Internal_Compile_Private_Print_Expression extends Smarty_Internal_C if (isset($compiler->smarty->autoload_filters[ Smarty::FILTER_VARIABLE ])) { foreach ((array) $compiler->template->smarty->autoload_filters[ Smarty::FILTER_VARIABLE ] as $name) { - $result = $this->compile_output_filter($compiler, $name, $output); + $result = $this->compile_variable_filter($compiler, $name, $output); if ($result !== false) { $output = $result; } else { // not found, throw exception - throw new SmartyException("Unable to load filter '{$name}'"); + throw new SmartyException("Unable to load variable filter '{$name}'"); } } } foreach ($compiler->variable_filters as $filter) { if (count($filter) === 1 && - ($result = $this->compile_output_filter($compiler, $filter[ 0 ], $output)) !== false + ($result = $this->compile_variable_filter($compiler, $filter[ 0 ], $output)) !== false ) { $output = $result; } else { @@ -134,28 +134,14 @@ class Smarty_Internal_Compile_Private_Print_Expression extends Smarty_Internal_C * @return string * @throws \SmartyException */ - private function compile_output_filter(Smarty_Internal_TemplateCompilerBase $compiler, $name, $output) + private function compile_variable_filter(Smarty_Internal_TemplateCompilerBase $compiler, $name, $output) { - $plugin_name = "smarty_variablefilter_{$name}"; - $path = $compiler->smarty->loadPlugin($plugin_name); - if ($path) { - /** - if ($compiler->template->caching) { - $compiler->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $name ][ Smarty::FILTER_VARIABLE ][ 'file' ] = - $path; - $compiler->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $name ][ Smarty::FILTER_VARIABLE ][ 'function' ] = - $plugin_name; - } else { - $compiler->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $name ][ Smarty::FILTER_VARIABLE ][ 'file' ] = - $path; - $compiler->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $name ][ Smarty::FILTER_VARIABLE ][ 'function' ] = - $plugin_name; - } - * */ - return "{$plugin_name}({$output},\$_smarty_tpl)"; - } else { + $function= $compiler->getPlugin($name, 'variablefilter'); + if ($function) { + return "{$function}({$output},\$_smarty_tpl)"; + } else { // not found return false; - } + } } }