From 5220ca6776aa3c7121069c2d06c1df8b8b39bf0d Mon Sep 17 00:00:00 2001 From: Uwe Tews Date: Mon, 6 Nov 2017 04:58:02 +0100 Subject: [PATCH] - bugfix {$smarty.section.name.loop} used together with {$smarty.section.name.total} could produce wrong results (forum topic 27041) 3.1.32-dev-35 --- change_log.txt | 2 ++ libs/Smarty.class.php | 2 +- libs/sysplugins/smarty_internal_compile_section.php | 13 ++++--------- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/change_log.txt b/change_log.txt index 5121a950..b753787d 100644 --- a/change_log.txt +++ b/change_log.txt @@ -2,6 +2,8 @@ 05.11.2017 - lexer/parser optimization - code cleanup and optimizations + - bugfix {$smarty.section.name.loop} used together with {$smarty.section.name.total} could produce + wrong results (forum topic 27041) 26.10.2017 - bugfix Smarty version was not filled in header comment of compiled and cached files diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index d497602a..54a5c39e 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -112,7 +112,7 @@ class Smarty extends Smarty_Internal_TemplateBase /** * smarty version */ - const SMARTY_VERSION = '3.1.32-dev-34'; + const SMARTY_VERSION = '3.1.32-dev-35'; /** * define variable scopes */ diff --git a/libs/sysplugins/smarty_internal_compile_section.php b/libs/sysplugins/smarty_internal_compile_section.php index e3e4dc34..8b4f5034 100644 --- a/libs/sysplugins/smarty_internal_compile_section.php +++ b/libs/sysplugins/smarty_internal_compile_section.php @@ -141,12 +141,7 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_Fo $v = "(is_array(@\$_loop=$attr_value) ? count(\$_loop) : max(0, (int) \$_loop))"; $t = 1; } - if (isset($namedAttr[ 'loop' ])) { - $initNamedProperty[ 'loop' ] = "'loop' => {$v}"; - if ($t === 1) { - $v = "{$sectionVar}->value['loop']"; - } - } elseif ($t === 1) { + if ($t === 1) { $initLocal[ 'loop' ] = $v; $v = "{$local}loop"; } @@ -338,7 +333,7 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_Fo } if (isset($namedAttr[ 'loop' ])) { - $initNamedProperty[ 'loop' ] = "'loop' => {$propValue['total']}"; + $initNamedProperty[ 'loop' ] = "'loop' => {$propValue['loop']}"; } if (isset($namedAttr[ 'total' ])) { $initNamedProperty[ 'total' ] = "'total' => {$propValue['total']}"; @@ -393,7 +388,7 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_Fo if (isset($namedAttr[ 'last' ])) { $output .= "{$sectionVar}->value['last'] = ({$propValue['iteration']} === {$propValue['total']});\n"; } - $output .= "?>"; + $output .= '?>'; return $output; } @@ -463,7 +458,7 @@ class Smarty_Internal_Compile_Sectionclose extends Smarty_Internal_CompileBase $output .= "if ({$local}saved) {\n"; $output .= "{$sectionVar} = {$local}saved;\n"; $output .= "}\n"; - $output .= "?>"; + $output .= '?>'; return $output; }