- bugfix {foreach} item variable must be created also on empty from array https://github.com/smarty-php/smarty/issues/238 and https://github.com/smarty-php/smarty/issues/239

This commit is contained in:
uwetews
2016-07-12 00:24:11 +02:00
parent b46a9a8dbd
commit b525d4d1d7
3 changed files with 8 additions and 9 deletions

View File

@@ -1,4 +1,7 @@
 ===== 3.1.30-dev ===== (xx.xx.xx)
12.07.2016
- bugfix {foreach} item variable must be created also on empty from array https://github.com/smarty-php/smarty/issues/238 and https://github.com/smarty-php/smarty/issues/239
27.05.2016
- bugfix/improvement of compileAlltemplates() follow symlinks in template folder (PHP >= 5.3.1) https://github.com/smarty-php/smarty/issues/224
clear internal cache and expension handler for each template to avoid possible conflicts https://github.com/smarty-php/smarty/issues/231

View File

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

View File

@@ -42,27 +42,23 @@ class Smarty_Internal_Runtime_Foreach
settype($from, 'array');
}
$total = ($needTotal || isset($properties[ 'total' ])) ? $this->count($from) : 1;
if (empty($from)) {
$from = null;
$total = 0;
if ($needTotal) {
if (isset($tpl->tpl_vars[ $item ])) {
$saveVars[ $item ] = $tpl->tpl_vars[ $item ];
}
$tpl->tpl_vars[ $item ] = new Smarty_Variable(null, $tpl->isRenderingCache);
if (empty($from)) {
$from = null;
$total = 0;
if ($needTotal) {
$tpl->tpl_vars[ $item ]->total = 0;
}
} else {
if (isset($tpl->tpl_vars[ $item ])) {
$saveVars[ $item ] = $tpl->tpl_vars[ $item ];
}
if ($key) {
if (isset($tpl->tpl_vars[ $key ])) {
$saveVars[ $key ] = $tpl->tpl_vars[ $key ];
}
$tpl->tpl_vars[ $key ] = new Smarty_Variable(null, $tpl->isRenderingCache);
}
$tpl->tpl_vars[ $item ] = new Smarty_Variable(null, $tpl->isRenderingCache);
if ($needTotal) {
$tpl->tpl_vars[ $item ]->total = $total;
}