Fix Block Settings TypeError: array_filter() when pressing Save configuration

Created on 8 June 2023, over 1 year ago
Updated 27 July 2023, over 1 year ago

Problem/Motivation

Facing the following

The website encountered an unexpected error. Please try again later.

TypeError: array_filter(): Argument #1 ($array) must be of type array, null given in array_filter() (line 80 of modules/contrib/cl_block/src/Form/SettingsForm.php).
Drupal\cl_block\Form\SettingsForm->submitForm()
call_user_func_array() (Line: 114)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers() (Line: 52)
Drupal\Core\Form\FormSubmitter->doSubmitForm() (Line: 597)
Drupal\Core\Form\FormBuilder->processForm() (Line: 325)
Drupal\Core\Form\FormBuilder->buildForm() (Line: 73)
Drupal\Core\Controller\FormController->getContentResult()
call_user_func_array() (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 583)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 166)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 74)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 54)
Drupal\simple_oauth\HttpMiddleware\BasicAuthSwap->handle() (Line: 58)
Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 704)
Drupal\Core\DrupalKernel->handle() (Line: 19)

Steps to reproduce

Given that the Component Libraries: Blocks module was installed
And the system has number of SDC components
When navigating to "/admin/config/user-interface/cl-components/block"
Then the list of "Refine selection" for "Forbidden components" and "Allowed components" will show up
And the scan system will trigger to have them listed
When I press the "Save configuration" submit button
Then the following fatal error shows up

TypeError: array_filter(): Argument #1 ($array) must be of type array, null given in array_filter() (line 80 of modules/contrib/cl_block/src/Form/SettingsForm.php).

Proposed resolution

  • Have a basic empty array values for complex filters
  • Check if the field values are arrays

Remaining tasks

  • File an issue
  • Patch/MR
  • Test
  • Review
  • Release

User interface changes

  • N/A

API changes

  • N/A

Data model changes

  • N/A
🐛 Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

🇯🇴Jordan Rajab Natshah Jordan

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024