为foreach()提供的参数无效

时间:2015-03-24 11:57:12

标签: php joomla joomla3.0 joomla3.4

你可以帮助我吗?我在所有PHP网站上遇到了这个失败:

代码是通过插件插入" NoNumber Sourcerer"在Joomla 3.4.1

bool(false) Warning: Invalid argument supplied for foreach() in /var/www/admin/libraries/class.System.php on line 117.

以下是class.system.php的第117行:

foreach ($result as $entry) {
    $modulePath = dirname(__FILE__) . '/../modules/' . $entry['DirectoryName'] . '/';

    if (is_dir($modulePath) && $entry['DirectoryName'] != '.' && $entry['DirectoryName'] != '..') {
        if (is_file($modulePath . 'index.php')) {
                require_once $modulePath . 'index.php';

                $class = new ReflectionClass($entry['Class']);

                $module = $class->newInstance();

                $this->modules[] = $module;

                foreach ($module->getActions() as $action) {
                    $this->moduleMappings[$action] = $module;
                }

                if ($entry['IsDefault'] != 0) {
                    //print_R($module);
                    $this->defaultModule = $module;
                }
            }
        }
    }
}

1 个答案:

答案 0 :(得分:0)

尝试检查$result是否包含值,并使用 -

更新代码
if($result != NULL && is_array($result)) {
    foreach ($result as $entry) {
         // your conditions
    }
}