From dde07d35fd4510b7ca26e61b973e037014a00c87 Mon Sep 17 00:00:00 2001 From: messju Date: Sat, 19 Mar 2005 18:28:46 +0000 Subject: [PATCH] objects don't get casted to arrays anymore in {foreach} --- NEWS | 1 + libs/Smarty_Compiler.class.php | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index bff5c989..77c54e44 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,4 @@ + - remove cast of object to array in foreach's from-attribute (messju) - add "null" as a valid token for {if} when security is enabled (messju) - add javascript_charcode encoding option to mailto function (monte) diff --git a/libs/Smarty_Compiler.class.php b/libs/Smarty_Compiler.class.php index 9311ae2c..5d0e6e6e 100644 --- a/libs/Smarty_Compiler.class.php +++ b/libs/Smarty_Compiler.class.php @@ -1176,14 +1176,15 @@ class Smarty_Compiler extends Smarty { } $output = '_foreach[$name]"; - $output .= "{$foreach_props} = array('total' => count(\$_from = (array)$from), 'iteration' => 0);\n"; + $output .= "{$foreach_props} = array('total' => count(\$_from), 'iteration' => 0);\n"; $output .= "if ({$foreach_props}['total'] > 0):\n"; $output .= " foreach (\$_from as $key_part\$this->_tpl_vars['$item']):\n"; $output .= " {$foreach_props}['iteration']++;\n"; } else { - $output .= "if (count(\$_from = (array)$from)):\n"; + $output .= "if (count(\$_from)):\n"; $output .= " foreach (\$_from as $key_part\$this->_tpl_vars['$item']):\n"; } $output .= '?>';