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 .= '?>';