Problem/Motivation
Type Error when saving configuration.
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 274 of modules/contrib/entity_usage/src/Form/EntityUsageSettingsForm.php).
array_filter(NULL) (Line: 274)
Drupal\entity_usage\Form\EntityUsageSettingsForm->submitForm(Array, Object)
Steps to reproduce
Configuration -> Content Authoring -> Entity Usage Settings
Select a desired Field from the ENABLED LOCAL TASKS
Save Configuration.
Proposed resolution
Apply the uploaded patch.
Comments
Comment #2
lucian_pana commentedComment #3
lucian_pana commentedComment #4
samitk commentedComment #5
samitk commentedHi @lucian_pana,
I tried to reproduce it, but not able to.
I am not sure why are you getting this error because in the following form field, the default value is array. SO the null given in array_filter() is not possible.
Please check again.
Thanks
Samit K.
Comment #6
drumanuel commentedSame problem here
* edit: removing module paragraphs_library seemed to fix this. *
Entity Usage 8.x-2.0-beta12
Drupal core 10.2.2
TypeError: array_filter(): Argument #1 ($array) must be of type array, null given in array_filter() (line 273 of modules/contrib/entity_usage/src/Form/EntityUsageSettingsForm.php).
Saving form causes this error out of the box.
config value local_task_enabled_entity_types is not returned by $this->config('entity_usage.settings') , breaking this code
array_filter($config->get('local_task_enabled_entity_types')) !== array_filter($form_state->getValue('local_task_enabled_entity_types')['entity_types']);
Full error log:
Drupal\entity_usage\Form\EntityUsageSettingsForm->submitForm(Array, Object)
call_user_func_array(Array, Array) (Line: 129)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 67)
Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 597)
Drupal\Core\Form\FormBuilder->processForm('entity_usage_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: 627)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
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: 28)
Drupal\Core\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 32)
Drupal\big_pipe\StackMiddleware\ContentLength->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: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Comment #7
dineshkumarbollu commentedHi
I try to reproduce the issue in Drupal 10.2 with Entity Usage 8.x-2.0-beta12 i am not getting any error. Configurations saved successfully.
if you still facing issue try this changes in the form.
Comment #8
stmh commentedI am experiencing the same error. The provided snippet fixes it for me.
Comment #9
smulvih2The issue is with this code on line 273:
When you first install the module and go to configure it,
$config->get('local_task_enabled_entity_types')will be NULL. So adding a simple?? []to ensure array_filter() has an empty array in this case would make sense.Comment #10
smulvih2Comment #11
mortona2k commented#10 fixed the error for me.
Comment #12
alexpott#9 is not correct - when you first install the module
$config->get('local_task_enabled_entity_types')will return an empty array.The reason this issue exists is because #2932559: Make it easier to access entity usage list of an entity did not have an upgrade path. We could add one here. It'd be something like
Comment #13
alexpottUsed a post update so we got config sorting for free.
Comment #15
alexpottComment #16
alexpottThis fixes the problem by providing the missing update path.
Comment #17
alexpottMerging...