Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 291085

TypeError: array_filter(): Argument #1 ($array) must be of type array, null given in array_filter() (line 431 of core/modules/menu_ui/menu_ui.module)

$
0
0

Problem/Motivation

Manually deleting the "Menu settings" form element throws the following error when creating a content:

The website encountered an unexpected error. Try again later.

TypeError: array_filter(): Argument #1 ($array) must be of type array, null given in array_filter() (line 431 of core/modules/menu_ui/menu_ui.module).
menu_ui_form_node_type_form_builder('node_type', Object, Array, Object)
call_user_func_array('menu_ui_form_node_type_form_builder', Array) (Line: 307)
Drupal\Core\Entity\EntityForm->buildEntity(Array, Object) (Line: 171)
Drupal\Core\Entity\EntityForm->afterBuild(Array, Object)
call_user_func_array(Array, Array) (Line: 1084)
Drupal\Core\Form\FormBuilder->doBuildForm('node_type_add_form', Array, Object) (Line: 579)
Drupal\Core\Form\FormBuilder->processForm('node_type_add_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}()
call_user_func_array(Object, Array) (Line: 177)
Drupal\static_preview_gatsby_instant\EventSubscriber\PreviewControllerWrapperSubscriber->wrapControllerExecutionInPreviewHandler(Object, Array, Object) (Line: 113)
Drupal\static_preview_gatsby_instant\EventSubscriber\PreviewControllerWrapperSubscriber->Drupal\static_preview_gatsby_instant\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: 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)

This is because the value of $form_state"menu_options" is NULL when processed in the PHP function array_filter().

Steps to reproduce

  1. Remove "Menu settings" form element from all node forms (preg_match('/node_(.*)_form/', $form_id) and unset($form['menu']);)
  2. Add content type and Save and manage fields.

Proposed resolution

Shielding the processing of $form_state->getValue('menu_options') within the PHP function array_filter() whether or not it is necessary to remove "Menu settings" will add robustness to the code.


Viewing all articles
Browse latest Browse all 291085

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>