mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 02:14:26 +02:00
- improvement do not compute total property in {foreach} if not needed https://github.com/smarty-php/smarty/issues/443
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
===== 3.1.33-dev-2 =====
|
===== 3.1.33-dev-3 =====
|
||||||
17.05.2018
|
17.05.2018
|
||||||
|
- improvement do not compute total property in {foreach} if not needed https://github.com/smarty-php/smarty/issues/443
|
||||||
- bugfix plugins may not be loaded when setMergeCompiledIncludes is true https://github.com/smarty-php/smarty/issues/435
|
- bugfix plugins may not be loaded when setMergeCompiledIncludes is true https://github.com/smarty-php/smarty/issues/435
|
||||||
|
|
||||||
26.04.2018
|
26.04.2018
|
||||||
|
@@ -112,7 +112,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
|||||||
/**
|
/**
|
||||||
* smarty version
|
* smarty version
|
||||||
*/
|
*/
|
||||||
const SMARTY_VERSION = '3.1.33-dev-2';
|
const SMARTY_VERSION = '3.1.33-dev-3';
|
||||||
/**
|
/**
|
||||||
* define variable scopes
|
* define variable scopes
|
||||||
*/
|
*/
|
||||||
|
@@ -37,17 +37,20 @@ class Smarty_Internal_Runtime_Foreach
|
|||||||
public function init(Smarty_Internal_Template $tpl, $from, $item, $needTotal = false, $key = null, $name = null,
|
public function init(Smarty_Internal_Template $tpl, $from, $item, $needTotal = false, $key = null, $name = null,
|
||||||
$properties = array())
|
$properties = array())
|
||||||
{
|
{
|
||||||
|
$needTotal = $needTotal || isset($properties[ 'total' ]);
|
||||||
$saveVars = array();
|
$saveVars = array();
|
||||||
$total = null;
|
$total = null;
|
||||||
if (!is_array($from)) {
|
if (!is_array($from)) {
|
||||||
if (is_object($from)) {
|
if (is_object($from)) {
|
||||||
|
if ($needTotal) {
|
||||||
$total = $this->count($from);
|
$total = $this->count($from);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
settype($from, 'array');
|
settype($from, 'array');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!isset($total)) {
|
if (!isset($total)) {
|
||||||
$total = empty($from) ? 0 : (($needTotal || isset($properties[ 'total' ])) ? count($from) : 1);
|
$total = empty($from) ? 0 : ($needTotal ? count($from) : 1);
|
||||||
}
|
}
|
||||||
if (isset($tpl->tpl_vars[ $item ])) {
|
if (isset($tpl->tpl_vars[ $item ])) {
|
||||||
$saveVars[ 'item' ] = array($item,
|
$saveVars[ 'item' ] = array($item,
|
||||||
|
Reference in New Issue
Block a user