phpjoomlajoomla3.0joomla3.4

Invalid argument supplied for foreach()


Hi can some one help me? I got on all PHP Site's this failure :

The Code is insert via Plugin "NoNumber Sourcerer" in Joomla 3.4.1

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

Here is Line 117 of the class.system.php :

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;
                }
            }
        }
    }
}

Solution

  • Try to check if $result has values and update your code with -

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