Warning: Invalid argument supplied for foreach()

Created on 8 December 2022, about 2 years ago
Updated 17 April 2023, almost 2 years ago

On clearing cache we get a nice error.

Warning: Invalid argument supplied for foreach() in Drupal\Component\Utility\NestedArray::mergeDeepArray() (line 327 of core/lib/Drupal/Component/Utility/NestedArray.php).
Drupal\Component\Utility\NestedArray::mergeDeepArray(Array) (Line: 295)
Drupal\Component\Utility\NestedArray::mergeDeep(Array, NULL) (Line: 452)
Drupal\views\EntityViewsData->mapFieldDefinition('civicrm_event', 'description', Object, Object, Array) (Line: 110)
Drupal\civicrm_entity\CivicrmEntityViewsData->getViewsData() (Line: 180)
views_views_data() (Line: 236)
Drupal\views\ViewsData->Drupal\views\{closure}(Object, 'views') (Line: 405)
Drupal\Core\Extension\ModuleHandler->invokeAllWith('views_data', Object) (Line: 244)
Drupal\views\ViewsData->getData() (Line: 154)
Drupal\views\ViewsData->get('aggregator_feed') (Line: 91)
Drupal\views\Plugin\Derivative\ViewsEntityRow->getDerivativeDefinitions(Array) (Line: 101)
Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator->getDerivatives(Array) (Line: 87)
Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator->getDefinitions() (Line: 285)
Drupal\Core\Plugin\DefaultPluginManager->findDefinitions() (Line: 175)
Drupal\Core\Plugin\DefaultPluginManager->getDefinitions() (Line: 22)
Drupal\Core\Plugin\DefaultPluginManager->getDefinition('data_field') (Line: 16)
Drupal\Core\Plugin\Factory\ContainerFactory->createInstance('data_field', Array) (Line: 83)
Drupal\Component\Plugin\PluginManagerBase->createInstance('data_field') (Line: 817)
Drupal\views\Plugin\views\display\DisplayPluginBase->getPlugin('row') (Line: 122)
Drupal\views\Plugin\views\style\StylePluginBase->init(Object, Object, Array) (Line: 820)
Drupal\views\Plugin\views\display\DisplayPluginBase->getPlugin('style') (Line: 346)
Drupal\rest\Plugin\views\display\RestExport->collectRoutes(Object) (Line: 120)
Drupal\views\EventSubscriber\RouteSubscriber->routes()
call_user_func(Array) (Line: 146)
Drupal\Core\Routing\RouteBuilder->rebuild() (Line: 83)
Drupal\Core\ProxyClass\Routing\RouteBuilder->rebuild() (Line: 587)
drupal_flush_all_caches() (Line: 205)
Drupal\admin_toolbar_tools\Controller\ToolbarController->flushAll()
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 564)
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: 709)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

There already seems to be a fix here: https://github.com/eileenmcnaughton/civicrm_entity/commit/2f68a448bbbe5d...

So attached is a patch for anyone else who runs into this issue until it is added into the module.

🐛 Bug report
Status

Fixed

Version

3.3

Component

Code

Created by

🇬🇧United Kingdom GHaddon

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇨🇦Canada nubeli

    I can confirm that this patch fixes the issue. Simple enough $views_field has to be an array so it should never be assigned anything else.

    Before patching:

    I see this error on many pages, including Extend, Admin Content, ...:

    Warning: foreach() argument must be of type array|object, null given in Drupal\Component\Utility\NestedArray::mergeDeepArray() (line 327 of core/lib/Drupal/Component/Utility/NestedArray.php).
    Drupal\Component\Utility\NestedArray::mergeDeepArray(Array) (Line: 295)
    Drupal\Component\Utility\NestedArray::mergeDeep(Array, NULL) (Line: 452)
    Drupal\views\EntityViewsData->mapFieldDefinition('civicrm_activity', 'details', Object, Object, Array) (Line: 110)

    After patching:

    No error.

  • Status changed to Fixed almost 2 years ago
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024