diff --git a/change_log.txt b/change_log.txt index 08c1d806..e8a59315 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,4 +1,7 @@  ===== 3.1.30-dev ===== (xx.xx.xx) + 13.07.2016 + - bugfix PHP 7 compatibility on registered compiler plugins https://github.com/smarty-php/smarty/issues/241 + 12.07.2016 - bugfix {foreach} item variable must be created also on empty from array https://github.com/smarty-php/smarty/issues/238 and https://github.com/smarty-php/smarty/issues/239 - bugfix enableSecurity() must init cache flags https://github.com/smarty-php/smarty/issues/247 diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index a21d776b..7ad0e4b2 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -121,7 +121,7 @@ class Smarty extends Smarty_Internal_TemplateBase /** * smarty version */ - const SMARTY_VERSION = '3.1.30-dev/74'; + const SMARTY_VERSION = '3.1.30-dev/75'; /** * define variable scopes diff --git a/libs/sysplugins/smarty_internal_templatecompilerbase.php b/libs/sysplugins/smarty_internal_templatecompilerbase.php index 2a5a3478..e2681800 100644 --- a/libs/sysplugins/smarty_internal_templatecompilerbase.php +++ b/libs/sysplugins/smarty_internal_templatecompilerbase.php @@ -588,15 +588,7 @@ abstract class Smarty_Internal_TemplateCompilerBase if (!$this->smarty->registered_plugins[ $plugin_type ][ $tag ][ 1 ]) { $this->tag_nocache = true; } - $function = $this->smarty->registered_plugins[ $plugin_type ][ $tag ][ 0 ]; - if (!is_array($function)) { - return $function($new_args, $this); - } elseif (is_object($function[ 0 ])) { - return $this->smarty->registered_plugins[ $plugin_type ][ $tag ][ 0 ][ 0 ]->{$function[ 1 ]}($new_args, - $this); - } else { - return call_user_func_array($function, array($new_args, $this)); - } + return call_user_func_array($this->smarty->registered_plugins[ $plugin_type ][ $tag ][ 0 ], array($new_args, $this)); } // compile registered function or block function if ($plugin_type == Smarty::PLUGIN_FUNCTION || $plugin_type == Smarty::PLUGIN_BLOCK) { @@ -669,15 +661,7 @@ abstract class Smarty_Internal_TemplateCompilerBase foreach ($args as $mixed) { $new_args = array_merge($new_args, $mixed); } - $function = $this->default_handler_plugins[ $plugin_type ][ $tag ][ 0 ]; - if (!is_array($function)) { - return $function($new_args, $this); - } elseif (is_object($function[ 0 ])) { - return $this->default_handler_plugins[ $plugin_type ][ $tag ][ 0 ][ 0 ]->$function[ 1 ]($new_args, - $this); - } else { - return call_user_func_array($function, array($new_args, $this)); - } + return call_user_func_array($this->default_handler_plugins[ $plugin_type ][ $tag ][ 0 ], array($new_args, $this)); } else { return $this->callTagCompiler('private_registered_' . $plugin_type, $args, $parameter, $tag); @@ -728,15 +712,7 @@ abstract class Smarty_Internal_TemplateCompilerBase if (!$this->smarty->registered_plugins[ Smarty::PLUGIN_COMPILER ][ $tag ][ 1 ]) { $this->tag_nocache = true; } - $function = $this->smarty->registered_plugins[ Smarty::PLUGIN_COMPILER ][ $tag ][ 0 ]; - if (!is_array($function)) { - return $function($args, $this); - } elseif (is_object($function[ 0 ])) { - return $this->smarty->registered_plugins[ Smarty::PLUGIN_COMPILER ][ $tag ][ 0 ][ 0 ]->$function[ 1 ]($args, - $this); - } else { - return call_user_func_array($function, array($args, $this)); - } + return call_user_func_array($this->smarty->registered_plugins[ Smarty::PLUGIN_COMPILER ][ $tag ][ 0 ], array($args, $this)); } if ($this->smarty->loadPlugin('smarty_compiler_' . $tag)) { $plugin = 'smarty_compiler_' . $tag; @@ -990,11 +966,6 @@ abstract class Smarty_Internal_TemplateCompilerBase $this->trigger_template_error("Default plugin handler: Returned script file \"{$script}\" for \"{$tag}\" not found"); } } - if (!is_string($callback) && - !(is_array($callback) && is_string($callback[ 0 ]) && is_string($callback[ 1 ])) - ) { - $this->trigger_template_error("Default plugin handler: Returned callback for \"{$tag}\" must be a static function name or array of class and function name"); - } if (is_callable($callback)) { $this->default_handler_plugins[ $plugin_type ][ $tag ] = array($callback, true, array());