0

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;
                }
            }
        }
    }
}
Attix2508
  • 5
  • 1
  • 5
  • The error is telling you that the value supplied to foreach is not an array. Check that your `$result` variable contains an array. Try doing: `var_dump($result);` and see what you get. – NaijaProgrammer Mar 24 '15 at 11:58
  • i updated the code in the question – Attix2508 Mar 24 '15 at 12:22
  • I think this error more related to Joomla setup instead of php coding error as error comes in a core file of Joomla. You need to change question details to show question as Joomla question or better move it to sister site http://joomla.stackexchange.com/ where it got Joomla specific attention. – kuldeep.kamboj Mar 24 '15 at 13:32
  • i insert the php code with the plugin "NoNumber Sourcerer" into joomla. The code was in use in a Typo3 Area without the error massage. – Attix2508 Mar 24 '15 at 13:38
  • possible duplicate of [Invalid argument supplied for foreach()](http://stackoverflow.com/questions/2630013/invalid-argument-supplied-for-foreach) – Félix Adriyel Gagnon-Grenier Jul 07 '15 at 18:58

1 Answers1

0

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

if($result != NULL && is_array($result)) {
    foreach ($result as $entry) {
         // your conditions
    }
}
TBI
  • 2,789
  • 1
  • 17
  • 21
  • And if `$result` is a string or a integer ? – Rizier123 Mar 24 '15 at 12:07
  • But I doubt that this will solve OP's real problem! I think the error is somewhere else in his code that he doesn't get an array – Rizier123 Mar 24 '15 at 12:14
  • might be, he can check and update here for further issues. We are here to help him :) – TBI Mar 24 '15 at 12:18
  • what is your output when you print $result ? Are you getting values in it, please update that as well in your question. – TBI Mar 24 '15 at 12:25
  • sorry, i'm not a profi with php. i'm updated the class.System.php . Now i see only " bool(false) " on every php site – Attix2508 Mar 24 '15 at 12:35