Incorrect handling of non countable values passed to `{foreach}`
authorAlexander Ebert <ebert@woltlab.com>
Tue, 23 Apr 2019 14:54:53 +0000 (16:54 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 23 Apr 2019 14:54:53 +0000 (16:54 +0200)
See 745a19744bf6e00843b8f66f24b8b08d409c4149

wcfsetup/install/files/lib/system/template/TemplateScriptingCompiler.class.php

index 010ea46ebefb5887df29ddc213bca2a2196baa87..de430c50eca671d7d1ec83904add914189ec30e9 100644 (file)
@@ -695,7 +695,7 @@ class TemplateScriptingCompiler {
                $phpCode .= $foreachHash." = ".$args['from'].";\n";
                
                if (empty($foreachProp)) {
-                       $phpCode .= "if ((is_countable(".$foreachHash.") && count(".$foreachHash.") > 0) || ".$foreachHash.") {\n";
+                       $phpCode .= "if ((is_countable(".$foreachHash.") && count(".$foreachHash.") > 0) || (!is_countable(".$foreachHash.") && ".$foreachHash.")) {\n";
                }
                else {
                        $phpCode .= $foreachHash."_cnt = (".$foreachHash." !== null ? 1 : 0);\n";