mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-05 10:54:27 +02:00
- bugfix {foreach} must keep the @properties when restoring a saved $item variable as the properties might be used outside {foreach} https://github.com/smarty-php/smarty/issues/267
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
===== 3.1.31-dev ===== (xx.xx.xx)
|
===== 3.1.31-dev ===== (xx.xx.xx)
|
||||||
09.09.2016
|
09.09.2016
|
||||||
- bugfix/optimization {foreach} did not execute the {foreachelse} when iterating empty objects https://github.com/smarty-php/smarty/pull/287
|
- bugfix/optimization {foreach} did not execute the {foreachelse} when iterating empty objects https://github.com/smarty-php/smarty/pull/287
|
||||||
|
- bugfix {foreach} must keep the @properties when restoring a saved $item variable as the properties might be used outside {foreach} https://github.com/smarty-php/smarty/issues/267
|
||||||
|
|
||||||
08.09.2016
|
08.09.2016
|
||||||
- bugfix implement wrapper for removed method getConfigVariable() https://github.com/smarty-php/smarty/issues/286
|
- bugfix implement wrapper for removed method getConfigVariable() https://github.com/smarty-php/smarty/issues/286
|
||||||
|
@@ -114,7 +114,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
|||||||
/**
|
/**
|
||||||
* smarty version
|
* smarty version
|
||||||
*/
|
*/
|
||||||
const SMARTY_VERSION = '3.1.31-dev/14';
|
const SMARTY_VERSION = '3.1.31-dev/15';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* define variable scopes
|
* define variable scopes
|
||||||
|
@@ -50,7 +50,7 @@ class Smarty_Internal_Runtime_Foreach
|
|||||||
$total = empty($from) ? 0 : (($needTotal || isset($properties[ 'total' ])) ? count($from) : 1);
|
$total = empty($from) ? 0 : (($needTotal || isset($properties[ 'total' ])) ? count($from) : 1);
|
||||||
}
|
}
|
||||||
if (isset($tpl->tpl_vars[ $item ])) {
|
if (isset($tpl->tpl_vars[ $item ])) {
|
||||||
$saveVars[ $item ] = $tpl->tpl_vars[ $item ];
|
$saveVars[ 'item' ] = array($item, $tpl->tpl_vars[ $item ]);
|
||||||
}
|
}
|
||||||
$tpl->tpl_vars[ $item ] = new Smarty_Variable(null, $tpl->isRenderingCache);
|
$tpl->tpl_vars[ $item ] = new Smarty_Variable(null, $tpl->isRenderingCache);
|
||||||
if ($total === 0) {
|
if ($total === 0) {
|
||||||
@@ -58,7 +58,7 @@ class Smarty_Internal_Runtime_Foreach
|
|||||||
} else {
|
} else {
|
||||||
if ($key) {
|
if ($key) {
|
||||||
if (isset($tpl->tpl_vars[ $key ])) {
|
if (isset($tpl->tpl_vars[ $key ])) {
|
||||||
$saveVars[ $key ] = $tpl->tpl_vars[ $key ];
|
$saveVars[ 'key' ] = array($key, $tpl->tpl_vars[ $key ]);
|
||||||
}
|
}
|
||||||
$tpl->tpl_vars[ $key ] = new Smarty_Variable(null, $tpl->isRenderingCache);
|
$tpl->tpl_vars[ $key ] = new Smarty_Variable(null, $tpl->isRenderingCache);
|
||||||
}
|
}
|
||||||
@@ -69,7 +69,7 @@ class Smarty_Internal_Runtime_Foreach
|
|||||||
if ($name) {
|
if ($name) {
|
||||||
$namedVar = "__smarty_foreach_{$name}";
|
$namedVar = "__smarty_foreach_{$name}";
|
||||||
if (isset($tpl->tpl_vars[ $namedVar ])) {
|
if (isset($tpl->tpl_vars[ $namedVar ])) {
|
||||||
$saveVars[ $namedVar ] = $tpl->tpl_vars[ $namedVar ];
|
$saveVars[ 'named' ] = array($namedVar, $tpl->tpl_vars[ $namedVar ]);
|
||||||
}
|
}
|
||||||
$namedProp = array();
|
$namedProp = array();
|
||||||
if (isset($properties[ 'total' ])) {
|
if (isset($properties[ 'total' ])) {
|
||||||
@@ -97,8 +97,16 @@ class Smarty_Internal_Runtime_Foreach
|
|||||||
*/
|
*/
|
||||||
public function restore(Smarty_Internal_Template $tpl)
|
public function restore(Smarty_Internal_Template $tpl)
|
||||||
{
|
{
|
||||||
foreach (array_pop($this->stack) as $k => $v) {
|
$saveVars = array_pop($this->stack);
|
||||||
$tpl->tpl_vars[ $k ] = $v;
|
if (isset($saveVars['item'])) {
|
||||||
|
$item = &$saveVars['item'];
|
||||||
|
$tpl->tpl_vars[ $item[0] ]->value = $item[1]->value;
|
||||||
|
}
|
||||||
|
if (isset($saveVars['key'])) {
|
||||||
|
$tpl->tpl_vars[ $saveVars['key'][0] ] = $saveVars['key'][1];
|
||||||
|
}
|
||||||
|
if (isset($saveVars['named'])) {
|
||||||
|
$tpl->tpl_vars[ $saveVars['named'][0] ] = $saveVars['named'][1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user