- bugfix {foreach} if key variable and item@key attribute have been used both the key variable was not updated https://github.com/smarty-php/smarty/issues/254

This commit is contained in:
uwetews
2016-07-18 05:27:46 +02:00
parent c666ec9a34
commit 79a4fdcd52
3 changed files with 7 additions and 4 deletions

View File

@@ -1,4 +1,7 @@
 ===== 3.1.30-dev ===== (xx.xx.xx)  ===== 3.1.30-dev ===== (xx.xx.xx)
18.07.2016
- bugfix {foreach} if key variable and item@key attribute have been used both the key variable was not updated https://github.com/smarty-php/smarty/issues/254
14.07.2016 14.07.2016
- bugfix wrong parameter on compileAllTemplates() and compileAllConfig() https://github.com/smarty-php/smarty/issues/231 - bugfix wrong parameter on compileAllTemplates() and compileAllConfig() https://github.com/smarty-php/smarty/issues/231

View File

@@ -121,7 +121,7 @@ class Smarty extends Smarty_Internal_TemplateBase
/** /**
* smarty version * smarty version
*/ */
const SMARTY_VERSION = '3.1.30-dev/80'; const SMARTY_VERSION = '3.1.30-dev/81';
/** /**
* define variable scopes * define variable scopes

View File

@@ -176,11 +176,11 @@ class Smarty_Internal_Compile_Foreach extends Smarty_Internal_Compile_Private_Fo
$itemAttr[ 'total' ] = true; $itemAttr[ 'total' ] = true;
} }
$keyTerm = ''; $keyTerm = '';
if (isset($attributes[ 'key' ])) {
$keyTerm = "\$_smarty_tpl->tpl_vars['{$key}']->value => ";
}
if (isset($itemAttr[ 'key' ])) { if (isset($itemAttr[ 'key' ])) {
$keyTerm = "{$itemVar}->key => "; $keyTerm = "{$itemVar}->key => ";
unset($itemAttr[ 'key' ]);
} elseif (isset($attributes[ 'key' ])) {
$keyTerm = "\$_smarty_tpl->tpl_vars['{$key}']->value => ";
} }
if ($this->isNamed) { if ($this->isNamed) {
$foreachVar = "\$_smarty_tpl->tpl_vars['__smarty_foreach_{$attributes['name']}']"; $foreachVar = "\$_smarty_tpl->tpl_vars['__smarty_foreach_{$attributes['name']}']";