Problem/Motivation
TypeError: array_merge(): Argument #1 must be of type array, null given in array_merge() (line 440 of modules/contrib/ui_patterns/src/Plugin/Derivative/EntityFieldSourceDeriverBase.php).
Steps to reproduce
When switching view mode in manage display
And change layout for the view mode to a component
Then I hit the following error
The website encountered an unexpected error. Try again later. TypeError: array_merge(): Argument #1 must be of type array, null given in array_merge() (line 440 of modules/contrib/ui_patterns/src/Plugin/Derivative/EntityFieldSourceDeriverBase.php). Drupal\ui_patterns\Plugin\Derivative\EntityFieldSourceDeriverBase->getDerivativeDefinitionsForEntityFieldStorages() (Line: 475) Drupal\ui_patterns\Plugin\Derivative\EntityFieldSourceDeriverBase->getDerivativeDefinitions() (Line: 101) Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator->getDerivatives() (Line: 87) Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator->getDefinitions() (Line: 337) Drupal\Core\Plugin\DefaultPluginManager->findDefinitions() (Line: 213) Drupal\Core\Plugin\DefaultPluginManager->getDefinitions() (Line: 23) Drupal\ui_patterns\SourcePluginManager->getDefinitionsForContexts() (Line: 61) Drupal\ui_patterns\SourcePluginManager->getDefinitionsMatchingContexts() (Line: 43) Drupal\ui_patterns\SourcePluginManager->getDefinitionsMatchingContextsAndTags() (Line: 154) Drupal\ui_patterns\SourcePluginManager->getNativeDefinitionsForPropType() (Line: 122) Drupal\ui_patterns\SourcePluginManager->getDefinitionsForPropType() (Line: 163) Drupal\ui_patterns\Element\ComponentFormBase::getSources() (Line: 154) Drupal\ui_patterns\Element\ComponentSlotForm::getSourceOptions() (Line: 305) Drupal\ui_patterns\Element\ComponentSlotForm::buildSourceSelector() (Line: 143) Drupal\ui_patterns\Element\ComponentSlotForm::buildForm() call_user_func_array() (Line: 1006) Drupal\Core\Form\FormBuilder->doBuildForm() (Line: 1069) Drupal\Core\Form\FormBuilder->doBuildForm() (Line: 1069) Drupal\Core\Form\FormBuilder->doBuildForm() (Line: 1069) Drupal\Core\Form\FormBuilder->doBuildForm() (Line: 1069) Drupal\Core\Form\FormBuilder->doBuildForm() (Line: 579) Drupal\Core\Form\FormBuilder->processForm() (Line: 326) Drupal\Core\Form\FormBuilder->buildForm() (Line: 73) Drupal\Core\Controller\FormController->getContentResult() (Line: 39) Drupal\layout_builder\Controller\LayoutBuilderHtmlEntityFormController->getContentResult() call_user_func_array() (Line: 123) Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 638) Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 121) Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97) Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181) Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76) Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 54) Drupal\simple_oauth\HttpMiddleware\BasicAuthSwap->handle() (Line: 53) Drupal\Core\StackMiddleware\Session->handle() (Line: 48) Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28) Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 32) Drupal\big_pipe\StackMiddleware\ContentLength->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: 36) Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 51) Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 741) Drupal\Core\DrupalKernel->handle() (Line: 19)
Proposed resolution
- Cast
$field_storage_data["bundles"]as(array) - make sure that all array_merge get arrays .. no string or NULL
Remaining tasks
- File an issue
- MR
- Test
- Review
User interface changes
API changes
Data model changes
Issue fork ui_patterns-3485290
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
rajab natshahComment #4
rajab natshahComment #6
just_like_good_vibesHello,
thank you for reporting this bug. i have updated a little bit your code change proposition and i will merge that.
thanks
Comment #7
just_like_good_vibesComment #9
just_like_good_vibesComment #10
rajab natshahThanks, Mikael, your method has better logic for the fix.
( more physical testing )