Skip to content

Commit

Permalink
- bugfix #368 did break the default plugin handler
Browse files Browse the repository at this point in the history
  • Loading branch information
uwetews committed May 27, 2017
1 parent ef889c7 commit ea93486
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
1 change: 1 addition & 0 deletions change_log.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion libs/Smarty.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $
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 ];
Expand All @@ -59,9 +61,18 @@ public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $
}
}
$_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' ],
Expand Down

0 comments on commit ea93486

Please sign in to comment.