diff --git a/change_log.txt b/change_log.txt index ac21d395..3914cbe6 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,6 +1,7 @@  ===== 3.1.22-dev ===== (xx.xx.2015) 20.03.2015 - bugfix make sure that function properties get saved only in compiled files containing the fuction definition {forum topic 25452} + - bugfix correct update of global variable values on exit of template functions. (reported under Smarty Developers) 16.03.2015 - bugfix problems with {function}{/function} and {call} tags in different subtemplate cache files {forum topic 25452} diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index 517f8c1a..01b814bc 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -111,7 +111,7 @@ class Smarty extends Smarty_Internal_TemplateBase /** * smarty version */ - const SMARTY_VERSION = '3.1.22-dev/15'; + const SMARTY_VERSION = '3.1.22-dev/16'; /** * define variable scopes diff --git a/libs/sysplugins/smarty_internal_compile_function.php b/libs/sysplugins/smarty_internal_compile_function.php index d9fe7ce5..d90665eb 100644 --- a/libs/sysplugins/smarty_internal_compile_function.php +++ b/libs/sysplugins/smarty_internal_compile_function.php @@ -164,8 +164,9 @@ class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase $compiler->parser->current_buffer->append_subtree(new Smarty_Internal_ParseTree_Tag($compiler->parser, $output)); $compiler->parser->current_buffer->append_subtree($_functionCode); $output = "template->properties['nocache_hash']}%%*/tpl_vars = \\\$saved_tpl_vars;\n"; - $output .= "foreach (Smarty::\\\$global_tpl_vars as \\\$key => \\\$value) if(!isset(\\\$_smarty_tpl->tpl_vars[\\\$key])) \\\$_smarty_tpl->tpl_vars[\\\$key] = \\\$value;?>"; + $output .= "foreach (Smarty::\\\$global_tpl_vars as \\\$key => \\\$value){\n"; + $output .= "if (\\\$_smarty_tpl->tpl_vars[\\\$key] === \\\$value) \\\$saved_tpl_vars[\\\$key] = \\\$value;\n}\n"; + $output .= "\\\$_smarty_tpl->tpl_vars = \\\$saved_tpl_vars;?>\n"; $output .= "/*/%%SmartyNocache:{$compiler->template->properties['nocache_hash']}%%*/\";\n?>"; $output .= "template->properties['nocache_hash']}', \$_smarty_tpl->properties['nocache_hash'], ob_get_clean());\n}\n}\n"; $output .= "/*/ {$_funcName}_nocache */\n\n"; @@ -194,8 +195,9 @@ class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase $output .= "foreach (\$params as \$key => \$value) {\n\$_smarty_tpl->tpl_vars[\$key] = new Smarty_Variable(\$value);\n}?>"; $compiler->parser->current_buffer->append_subtree(new Smarty_Internal_ParseTree_Tag($compiler->parser, $output)); $compiler->parser->current_buffer->append_subtree($_functionCode); - $output = "tpl_vars = \$saved_tpl_vars;\n"; - $output .= "foreach (Smarty::\$global_tpl_vars as \$key => \$value) if(!isset(\$_smarty_tpl->tpl_vars[\$key])) \$_smarty_tpl->tpl_vars[\$key] = \$value;\n}\n}\n"; + $output = " \$value){\n"; + $output .= "if (\$_smarty_tpl->tpl_vars[\$key] === \$value) \$saved_tpl_vars[\$key] = \$value;\n}\n"; + $output .= "\$_smarty_tpl->tpl_vars = \$saved_tpl_vars;\n}\n}\n"; $output .= "/*/ {$_funcName} */\n\n"; $output .= "?>\n"; $compiler->parser->current_buffer->append_subtree(new Smarty_Internal_ParseTree_Tag($compiler->parser, $output));