From ea934861356f635269ec415964cf3353c92949ee Mon Sep 17 00:00:00 2001 From: uwetews Date: Sat, 27 May 2017 12:18:43 +0200 Subject: [PATCH] - bugfix https://github.com/smarty-php/smarty/pull/368 did break the default plugin handler --- change_log.txt | 1 + libs/Smarty.class.php | 2 +- ...rnal_compile_private_registered_function.php | 17 ++++++++++++++--- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/change_log.txt b/change_log.txt index 786dff78..0b9dab65 100644 --- a/change_log.txt +++ b/change_log.txt @@ -2,6 +2,7 @@ 27.5.2017 - bugfix change compiled code for registered function and modifiers to called as callable to allow closures https://github.com/smarty-php/smarty/pull/368 + - bugfix https://github.com/smarty-php/smarty/pull/368 did break the default plugin handler 21.5.2017 - performance store flag for already required shared plugin functions in static variable or diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index d9d5dcdf..857bdea0 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -108,7 +108,7 @@ class Smarty extends Smarty_Internal_TemplateBase /** * smarty version */ - const SMARTY_VERSION = '3.1.32-dev-9'; + const SMARTY_VERSION = '3.1.32-dev-10'; /** * define variable scopes diff --git a/libs/sysplugins/smarty_internal_compile_private_registered_function.php b/libs/sysplugins/smarty_internal_compile_private_registered_function.php index 5716e400..3754f2b0 100644 --- a/libs/sysplugins/smarty_internal_compile_private_registered_function.php +++ b/libs/sysplugins/smarty_internal_compile_private_registered_function.php @@ -41,8 +41,10 @@ class Smarty_Internal_Compile_Private_Registered_Function extends Smarty_Interna unset($_attr[ 'nocache' ]); if (isset($compiler->smarty->registered_plugins[ Smarty::PLUGIN_FUNCTION ][ $tag ])) { $tag_info = $compiler->smarty->registered_plugins[ Smarty::PLUGIN_FUNCTION ][ $tag ]; + $is_registered = true; } else { - $tag_info = $compiler->default_handler_plugins[ Smarty::PLUGIN_FUNCTION ][ $tag ]; + $tag_info = $compiler->default_handler_plugins[ Smarty::PLUGIN_FUNCTION ][ $tag ]; + $is_registered = false; } // not cacheable? $compiler->tag_nocache = $compiler->tag_nocache || !$tag_info[ 1 ]; @@ -59,9 +61,18 @@ class Smarty_Internal_Compile_Private_Registered_Function extends Smarty_Interna } } $_params = 'array(' . implode(",", $_paramsArray) . ')'; - $function = $tag_info[ 0 ]; // compile code - $output = "call_user_func_array( \$_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['{$tag}'][0], array( {$_params},\$_smarty_tpl ) )"; + if ($is_registered) { + $output = + "call_user_func_array( \$_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['{$tag}'][0], array( {$_params},\$_smarty_tpl ) )"; + } else { + $function = $tag_info[ 0 ]; + if (!is_array($function)) { + $output = "{$function}({$_params},\$_smarty_tpl)"; + } else { + $output = "{$function[0]}::{$function[1]}({$_params},\$_smarty_tpl)"; + } + } if (!empty($parameter[ 'modifierlist' ])) { $output = $compiler->compileTag('private_modifier', array(), array('modifierlist' => $parameter[ 'modifierlist' ],