diff --git a/change_log.txt b/change_log.txt index 15cc4a04..c5e7a146 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,6 +1,7 @@  ===== 3.1.24.dev ===== (xx.xx.2015) - bugfix {$smarty.constant.TEST} did fail on undefined constant https://github.com/smarty-php/smarty/issues/28 - bugfix access to undefined config variable like {#undef#} did fail https://github.com/smarty-php/smarty/issues/29 + - bugfix in nested {foreach} saved item attributes got overwritten https://github.com/smarty-php/smarty/issues/33 ===== 3.1.23 ===== (12.05.2015) 12.05.2015 diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index ae43b0ab..376fb98e 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.24-dev/1'; + const SMARTY_VERSION = '3.1.24-dev/2'; /** * define variable scopes diff --git a/libs/sysplugins/smarty_internal_compile_foreach.php b/libs/sysplugins/smarty_internal_compile_foreach.php index e117a4a1..82ea4963 100644 --- a/libs/sysplugins/smarty_internal_compile_foreach.php +++ b/libs/sysplugins/smarty_internal_compile_foreach.php @@ -208,7 +208,8 @@ class Smarty_Internal_Compile_Foreach extends Smarty_Internal_CompileBase } } } - $output .= "\$foreachItemSav = \$_smarty_tpl->tpl_vars[$item];\n"; + $itemName = trim($item,"'\""); + $output .= "\$foreach_{$itemName}_Sav = \$_smarty_tpl->tpl_vars[$item];\n"; $output .= "?>"; return $output; @@ -239,8 +240,9 @@ class Smarty_Internal_Compile_Foreachelse extends Smarty_Internal_CompileBase list($openTag, $nocache, $item, $key, $foo) = $this->closeTag($compiler, array('foreach')); $this->openTag($compiler, 'foreachelse', array('foreachelse', $nocache, $item, $key, false)); + $itemName = trim($item,"'\""); $output = "tpl_vars[$item] = \$foreachItemSav;\n"; + $output .= "\$_smarty_tpl->tpl_vars[$item] = \$foreach_{$itemName}_Sav;\n"; $output .= "}\n"; $output .= "if (!\$_smarty_tpl->tpl_vars[$item]->_loop) {\n?>"; return $output; @@ -274,9 +276,10 @@ class Smarty_Internal_Compile_Foreachclose extends Smarty_Internal_CompileBase } list($openTag, $compiler->nocache, $item, $key, $restore) = $this->closeTag($compiler, array('foreach', 'foreachelse')); + $itemName = trim($item,"'\""); $output = "tpl_vars[$item] = \$foreachItemSav;\n"; + $output .= "\$_smarty_tpl->tpl_vars[$item] = \$foreach_{$itemName}_Sav;\n"; } $output .= "}\n?>";