mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 18:34:27 +02:00
- bugfix change compiled code for registered function and modifiers to called as callable to allow closures
https://github.com/smarty-php/smarty/pull/368
This commit is contained in:
@@ -1,4 +1,8 @@
|
||||
===== 3.1.32 - dev ===
|
||||
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
|
||||
|
||||
21.5.2017
|
||||
- performance store flag for already required shared plugin functions in static variable or
|
||||
Smarty's $_cache to improve performance when plugins are often called
|
||||
|
@@ -108,7 +108,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
/**
|
||||
* smarty version
|
||||
*/
|
||||
const SMARTY_VERSION = '3.1.32-dev-8';
|
||||
const SMARTY_VERSION = '3.1.32-dev-9';
|
||||
|
||||
/**
|
||||
* define variable scopes
|
||||
|
@@ -48,20 +48,13 @@ class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBa
|
||||
case 1:
|
||||
// registered modifier
|
||||
if (isset($compiler->smarty->registered_plugins[ Smarty::PLUGIN_MODIFIER ][ $modifier ])) {
|
||||
$function =
|
||||
$compiler->smarty->registered_plugins[ Smarty::PLUGIN_MODIFIER ][ $modifier ][ 0 ];
|
||||
if (!is_array($function)) {
|
||||
$output = "{$function}({$params})";
|
||||
} else {
|
||||
if (is_object($function[ 0 ])) {
|
||||
$output = '$_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER][\'' .
|
||||
$modifier . '\'][0][0]->' . $function[ 1 ] . '(' . $params . ')';
|
||||
} else {
|
||||
$output = $function[ 0 ] . '::' . $function[ 1 ] . '(' . $params . ')';
|
||||
}
|
||||
if (is_callable($compiler->smarty->registered_plugins[ Smarty::PLUGIN_MODIFIER ][ $modifier ][ 0 ])) {
|
||||
$output =
|
||||
sprintf('call_user_func_array($_smarty_tpl->registered_plugins[ \'%s\' ][ %s ][ 0 ], array( %s ))',
|
||||
Smarty::PLUGIN_MODIFIER, var_export($modifier, true), $params);
|
||||
$compiler->known_modifier_type[ $modifier ] = $type;
|
||||
break 2;
|
||||
}
|
||||
$compiler->known_modifier_type[ $modifier ] = $type;
|
||||
break 2;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
@@ -154,4 +147,4 @@ class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBa
|
||||
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
}
|
@@ -61,14 +61,7 @@ class Smarty_Internal_Compile_Private_Registered_Function extends Smarty_Interna
|
||||
$_params = 'array(' . implode(",", $_paramsArray) . ')';
|
||||
$function = $tag_info[ 0 ];
|
||||
// compile code
|
||||
if (!is_array($function)) {
|
||||
$output = "{$function}({$_params},\$_smarty_tpl)";
|
||||
} elseif (is_object($function[ 0 ])) {
|
||||
$output =
|
||||
"\$_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['{$tag}'][0][0]->{$function[1]}({$_params},\$_smarty_tpl)";
|
||||
} else {
|
||||
$output = "{$function[0]}::{$function[1]}({$_params},\$_smarty_tpl)";
|
||||
}
|
||||
$output = "call_user_func_array( \$_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['{$tag}'][0], array( {$_params},\$_smarty_tpl ) )";
|
||||
if (!empty($parameter[ 'modifierlist' ])) {
|
||||
$output = $compiler->compileTag('private_modifier', array(),
|
||||
array('modifierlist' => $parameter[ 'modifierlist' ],
|
||||
@@ -79,4 +72,4 @@ class Smarty_Internal_Compile_Private_Registered_Function extends Smarty_Interna
|
||||
$output = "<?php echo {$output};?>\n";
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user