mirror of
https://github.com/smarty-php/smarty.git
synced 2025-09-25 20:00:54 +02:00
Merge pull request #566 from smarty-php/bugfix/506_foreachelse_on_arrayiterators
Bugfix/506 foreachelse on arrayiterators
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
- fix foreachelse on arrayiterators https://github.com/smarty-php/smarty/issues/506
|
||||||
|
|
||||||
===== 3.1.34 release ===== 05.11.2019
|
===== 3.1.34 release ===== 05.11.2019
|
||||||
13.01.2020
|
13.01.2020
|
||||||
- fix typo in exception message (JercSi)
|
- fix typo in exception message (JercSi)
|
||||||
|
@@ -219,8 +219,9 @@ class Smarty_Internal_Compile_Foreach extends Smarty_Internal_Compile_Private_Fo
|
|||||||
if (isset($itemAttr[ 'index' ])) {
|
if (isset($itemAttr[ 'index' ])) {
|
||||||
$output .= "{$itemVar}->index = -1;\n";
|
$output .= "{$itemVar}->index = -1;\n";
|
||||||
}
|
}
|
||||||
$output .= "if (\$_from !== null) {\n";
|
$output .= "{$itemVar}->do_else = true;\n";
|
||||||
$output .= "foreach (\$_from as {$keyTerm}{$itemVar}->value) {\n";
|
$output .= "if (\$_from !== null) foreach (\$_from as {$keyTerm}{$itemVar}->value) {\n";
|
||||||
|
$output .= "{$itemVar}->do_else = false;\n";
|
||||||
if (isset($attributes[ 'key' ]) && isset($itemAttr[ 'key' ])) {
|
if (isset($attributes[ 'key' ]) && isset($itemAttr[ 'key' ])) {
|
||||||
$output .= "\$_smarty_tpl->tpl_vars['{$key}']->value = {$itemVar}->key;\n";
|
$output .= "\$_smarty_tpl->tpl_vars['{$key}']->value = {$itemVar}->key;\n";
|
||||||
}
|
}
|
||||||
@@ -296,7 +297,7 @@ class Smarty_Internal_Compile_Foreachelse extends Smarty_Internal_CompileBase
|
|||||||
if ($restore === 2) {
|
if ($restore === 2) {
|
||||||
$output .= "{$itemVar} = {$local}saved;\n";
|
$output .= "{$itemVar} = {$local}saved;\n";
|
||||||
}
|
}
|
||||||
$output .= "}\n} else {\n?>";
|
$output .= "}\nif ({$itemVar}->do_else) {\n?>";
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -332,9 +333,6 @@ class Smarty_Internal_Compile_Foreachclose extends Smarty_Internal_CompileBase
|
|||||||
if ($restore === 2) {
|
if ($restore === 2) {
|
||||||
$output .= "{$itemVar} = {$local}saved;\n";
|
$output .= "{$itemVar} = {$local}saved;\n";
|
||||||
}
|
}
|
||||||
if ($restore > 0) {
|
|
||||||
$output .= "}\n";
|
|
||||||
}
|
|
||||||
$output .= "}\n";
|
$output .= "}\n";
|
||||||
/* @var Smarty_Internal_Compile_Foreach $foreachCompiler */
|
/* @var Smarty_Internal_Compile_Foreach $foreachCompiler */
|
||||||
$foreachCompiler = $compiler->getTagCompiler('foreach');
|
$foreachCompiler = $compiler->getTagCompiler('foreach');
|
||||||
|
Reference in New Issue
Block a user