I have the warning when opening the status page admin/reports below. I am not sure if it is caused by other modules or not. Can you help examining this? Thanks.
Warning: Invalid argument supplied for foreach() in Drupal\system\Element\StatusReportPage::preRenderGeneralInfo() (line 42 of core/modules/system/src/Element/StatusReportPage.php).
Drupal\system\Element\StatusReportPage::preRenderGeneralInfo(Array)
call_user_func(Array, Array) (Line: 376)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer->render(Array, ) (Line: 226)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 574)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 227)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 117)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object) (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.view', Object) (Line: 149)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 64)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 656)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Comments

danghoaiphuc created an issue. See original summary.

cilefen’s picture

Priority: Normal » Major

The problem here is that for some reason the section of system_requirements() that sets that cron key has not set #description to be an array.

cilefen’s picture

Title: Warning When Checking Drupal 8.3.2 Status Page » Warning: Invalid argument supplied for foreach() in Drupal\system\Element\StatusReportPage::preRenderGeneralInfo() on status page
danghoaiphuc’s picture

Thanks Celifen. Do you have any suggested solution for this warning?

Alex Andrascu’s picture

Confirmed. Getting this on Drupal core 8.3.2

rpmarchitecture’s picture

I can confirm the same error initially with 8.3.2, and persists after upgrading core to 8.3.3 and 8.3.4. Everything else on the site appears in order and functioning properly. Any ideas to try to resolve?

Anonymous’s picture

I am having the same problem too and I can not figure it out:

Warning: Invalid argument supplied for foreach() in Drupal\system\Element\StatusReportPage::preRenderGeneralInfo() (line 42 of core/modules/system/src/Element/StatusReportPage.php).
Drupal\system\Element\StatusReportPage::preRenderGeneralInfo(Array)
call_user_func(Array, Array) (Line: 376)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer->render(Array, ) (Line: 226)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 574)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 227)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 117)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object) (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.view', Object) (Line: 149)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 64)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 50)
Drupal\ban\BanMiddleware->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 656)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

mogio_hh’s picture

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

rpmarchitecture’s picture

The patch does not seem to work for me. Can you describe what you are doing with the patch?

wnymathguy’s picture

Just wanted to chime in here. I get the
"Warning: Invalid argument supplied for foreach() in Drupal\system\Element\StatusReportPage::preRenderGeneralInfo() (line 42 of core/modules/system/src/Element/StatusReportPage.php)."
message on /admin/reports/status and I'm in Drupal Version 8.3.7
HOWEVER, I get it in my https version of my site not my http version. The main difference is the https site has Ubercart installed. The rest of the modules are close to identical. Would more info from me help anybody diagnose it? I'm a newbie here so don't know what is relevant.

hugronaphor’s picture

One of the reason would be that some of your modules are defining the requirements without a specific key(e.g: $requirements[] = [...]; ).
By specifying a key the error will be gone (e.g: $requirements['mymodule_compoonent'] = [...]; )

romreactor’s picture

Version: 8.4.x-dev » 8.4.0

Hello,

I attempted this patch on my Drupal 8.4.0 version since this issue has reappeared. However, I completely got a broken StatusReportPage.

Please take a look at this error message that I am receiving after updating to Drupal 8.4 from Drupal 8.3.7 and applying the patch to my error listed as Warning below..

The website encountered an unexpected error. Please try again later.
ParseError: syntax error, unexpected '}' in Composer\Autoload\includeFile() (line 57 of core/modules/system/src/Element/StatusReportPage.php).

I reverted the file to its previous version before this patch attempt, however on my report status I still receive this Warning message and am unable to update my Drupal database.

Warning: Invalid argument supplied for foreach() in Drupal\system\Element\StatusReportPage::preRenderGeneralInfo() (line 42 of core/modules/system/src/Element/StatusReportPage.php).
Drupal\system\Element\StatusReportPage::preRenderGeneralInfo(Array)
call_user_func(Array, Array) (Line: 378)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer->render(Array, ) (Line: 226)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 576)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 227)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 117)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object) (Line: 108)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.view', Object) (Line: 158)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 657)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

ShannonMcG’s picture

Thanks to hugronaphor's comment #12, I found two places in the Ubercart module installed on my site that had used "$requirements[]" without a key. I added a key and the errors went away.

I'm running Drupal Version 8.5.3 and Ubercart 8.x-4.0-alpha5.

Problem code:

/modules/contrib/ubercart/uc_store/src/Controller/StoreController.php:
   22        ];
   23        foreach ($results as $message) {
   24:         $requirements[] = [
   25            'title' => $message['title'],
   26            'description' => $message['desc'],

/modules/contrib/ubercart/uc_store/uc_store.install:
   20      $results = \Drupal::moduleHandler()->invokeAll('uc_store_status');
   21      foreach ($results as $status) {
   22:       $requirements[] = array(
   23          'severity' => isset($severities[$status['status']]) ? $severities[$status['status']] : NULL,
   24          'title' => $status['title'],

Fixed code:

/modules/contrib/ubercart/uc_store/src/Controller/StoreController.php:
   22        ];
   23        foreach ($results as $message) {
   24:         $requirements['uc_message'] = [
   25            'title' => $message['title'],
   26            'description' => $message['desc'],

/modules/contrib/ubercart/uc_store/uc_store.install:
   20      $results = \Drupal::moduleHandler()->invokeAll('uc_store_status');
   21      foreach ($results as $status) {
   22:       $requirements['uc_message'] = array(
   23          'severity' => isset($severities[$status['status']]) ? $severities[$status['status']] : NULL,
   24          'title' => $status['title'],
bjaxelsen’s picture

I think this is related, I need to add an empty description key in uc_store_requirements to make error message on status page go away:

function uc_store_requirements($phase) {
  $requirements = [];

  if ($phase == 'runtime') {
    $severities = [
      'warning' => REQUIREMENT_WARNING,
      'error' => REQUIREMENT_ERROR,
    ];

    $results = \Drupal::moduleHandler()->invokeAll('uc_store_status');
    foreach ($results as $status) {
      $requirements[] = [
        'severity' => isset($severities[$status['status']]) ? $severities[$status['status']] : NULL,
        'title' => $status['title'],
        'value' => $status['desc'],
        'description' => [],
      ];
    }
  }

  return $requirements;
}
yosia_ken’s picture

#17 works!

Graham Leach’s picture

Hello Everyone.

Bjorn, great work - but just a little light on context and details, IMHO...

For those of us who are not Drupal Core Team, Engineers or even Developers, I have written a more extensive article about this fix on my website - along with dozens of other D6, D7 and D8 fixes - in vernacular I believe is more in tune with the needs and communication requirements of regular people.

Here you go: https://bit.ly/2XNvvAV

Graham Leach

Version: 8.4.0 » 8.4.x-dev

Core issues are now filed against the dev versions where changes will be made. Document the specific release you are using in your issue comment. More information about choosing a version.

Version: 8.4.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Branches prior to 8.8.x are not supported, and Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

rubbeng’s picture

Warning: Invalid argument supplied for foreach() in content_moderation_requirements() (line 23 of /home/u753365889/public_html/core/modules/content_moderation/content_moderation.install)

#0 /home/u753365889/public_html/core/includes/bootstrap.inc(600): _drupal_error_handler_real(2, 'Invalid argumen...', '/home/u75336588...', 23, Array)
#1 /home/u753365889/public_html/core/modules/content_moderation/content_moderation.install(23): _drupal_error_handler(2, 'Invalid argumen...', '/home/u75336588...', 23, Array)
#2 [internal function]: content_moderation_requirements('runtime')
#3 /home/u753365889/public_html/core/lib/Drupal/Core/Extension/ModuleHandler.php(403): call_user_func_array('content_moderat...', Array)
#4 /home/u753365889/public_html/core/modules/system/src/SystemManager.php(111): Drupal\Core\Extension\ModuleHandler->invokeAll('requirements', Array)
#5 /home/u753365889/public_html/core/modules/system/src/Controller/SystemInfoController.php(49): Drupal\system\SystemManager->listRequirements()
#6 [internal function]: Drupal\system\Controller\SystemInfoController->status()
#7 /home/u753365889/public_html/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
#8 /home/u753365889/public_html/core/lib/Drupal/Core/Render/Renderer.php(573): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#9 /home/u753365889/public_html/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#10 /home/u753365889/public_html/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
#11 /home/u753365889/public_html/vendor/symfony/http-kernel/HttpKernel.php(151): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#12 /home/u753365889/public_html/vendor/symfony/http-kernel/HttpKernel.php(68): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#13 /home/u753365889/public_html/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#14 /home/u753365889/public_html/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#15 /home/u753365889/public_html/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#16 /home/u753365889/public_html/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#17 /home/u753365889/public_html/core/modules/ban/src/BanMiddleware.php(50): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#18 /home/u753365889/public_html/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\ban\BanMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#19 /home/u753365889/public_html/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(52): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#20 /home/u753365889/public_html/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#21 /home/u753365889/public_html/core/lib/Drupal/Core/DrupalKernel.php(708): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#22 /home/u753365889/public_html/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#23 {main}
pameeela’s picture

Status: Active » Closed (works as designed)
Issue tags: +Bug Smash Initiative

I'm going to close this since numerous comments indicate this was an issue with custom or contrib module code. Comments #12, #16, #17 and #19 contain useful tips for how to fix it.