mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-03 18:04: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
|
||||
- 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
|
||||
|
||||
26.04.2018
|
||||
|
@@ -112,7 +112,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
/**
|
||||
* smarty version
|
||||
*/
|
||||
const SMARTY_VERSION = '3.1.33-dev-2';
|
||||
const SMARTY_VERSION = '3.1.33-dev-3';
|
||||
/**
|
||||
* 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,
|
||||
$properties = array())
|
||||
{
|
||||
$needTotal = $needTotal || isset($properties[ 'total' ]);
|
||||
$saveVars = array();
|
||||
$total = null;
|
||||
if (!is_array($from)) {
|
||||
if (is_object($from)) {
|
||||
$total = $this->count($from);
|
||||
if ($needTotal) {
|
||||
$total = $this->count($from);
|
||||
}
|
||||
} else {
|
||||
settype($from, 'array');
|
||||
}
|
||||
}
|
||||
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 ])) {
|
||||
$saveVars[ 'item' ] = array($item,
|
||||
|
Reference in New Issue
Block a user