- Issue created by @richardhobbs
- Status changed to Needs work
about 1 year ago 11:15am 30 August 2023 - 🇩🇰Denmark bartvig
I'm going to need some more information. I can't reproduce the error on a freshly installed Drupal 10.1.0 or Drupal 10.1.2.
The only way I can see that any checkboxes in SettingsForm.php could be null and thus producing the mentioned error, is if
node_type_get_names();
returnsnull
, and the documentation says it returnsstring[]
, so I'm puzzled as to how you can get this error.If either there are no node types, taxonomy types, or group types (and the group module has been enabled), then all the checkboxes variables will be empty arrays which is fine.
- 🇫🇮Finland Alexander Tallqvist
Im getting the same error on Drupal 9.5.9 when I just upgraded the module from version 2.0.0 to 2.0.1. Here is the full output:
Error message
Warning: foreach() argument must be of type array|object, null given in Drupal\Core\Render\Element\Checkboxes::valueCallback() (line 113 of core/lib/Drupal/Core/Render/Element/Checkboxes.php).Drupal\Core\Render\Element\Checkboxes::valueCallback(Array, , Object) call_user_func_array(Array, Array) (Line: 1287) Drupal\Core\Form\FormBuilder->handleInputElement('siteimprove_settings_form', Array, Object) (Line: 1005) Drupal\Core\Form\FormBuilder->doBuildForm('siteimprove_settings_form', Array, Object) (Line: 1075) Drupal\Core\Form\FormBuilder->doBuildForm('siteimprove_settings_form', Array, Object) (Line: 1075) Drupal\Core\Form\FormBuilder->doBuildForm('siteimprove_settings_form', Array, Object) (Line: 1075) Drupal\Core\Form\FormBuilder->doBuildForm('siteimprove_settings_form', Array, Object) (Line: 579) Drupal\Core\Form\FormBuilder->processForm('siteimprove_settings_form', Array, Object) (Line: 325) Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73) Drupal\Core\Controller\FormController->getContentResult(Object, Object) call_user_func_array(Array, Array) (Line: 123) Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 580) Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124) Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97) Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 169) Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 81) Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58) Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48) Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106) Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85) Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48) Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51) Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23) Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 718) Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
The problem lies in the default values for some of the checkboxes. '#default_value' => $config->get('enabled_content_types') might be returning NULL, which is causing the warning. Applying the patch from the original issue seems to fix the problem for me.
-
richardhobbs →
authored 97e1ea57 on 2.0.x
Issue #3375607 by richardhobbs: Warning: foreach() argument must be of...
-
richardhobbs →
authored 97e1ea57 on 2.0.x
- Status changed to Fixed
11 months ago 1:48pm 4 January 2024 Automatically closed - issue fixed for 2 weeks with no activity.