Drupal\views\EntityViewsData::mapFieldDefinition() Error 10.1.x

Created on 22 September 2023, over 1 year ago
Updated 20 September 2024, 3 months ago

After upgrading from 10.0.x to 10.1.x the site fails to load with the following error:

TypeError: Drupal\views\EntityViewsData::mapFieldDefinition(): Argument #5 ($data) must be of type array, null given, called in \web\core\modules\views\src\EntityViewsData.php on line 333 in Drupal\views\EntityViewsData->mapFieldDefinition() (line 442 of core\modules\views\src\EntityViewsData.php).

Drupal\views\EntityViewsData->getViewsData() (Line: 16)
Drupal\taxonomy\TermViewsData->getViewsData() (Line: 180)
views_views_data() (Line: 236)
Drupal\views\ViewsData->Drupal\views\{closure}(Object, 'views') (Line: 388)
Drupal\Core\Extension\ModuleHandler->invokeAllWith('views_data', Object) (Line: 244)
Drupal\views\ViewsData->getData() (Line: 154)
Drupal\views\ViewsData->get('block_content') (Line: 94)
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: 291)
Drupal\Core\Plugin\DefaultPluginManager->findDefinitions() (Line: 181)
Drupal\Core\Plugin\DefaultPluginManager->getDefinitions() (Line: 146)
views_theme(Array, 'module', 'views', 'core/modules/views') (Line: 455)
Drupal\Core\Theme\Registry->processExtension(Array, 'views', 'module', 'views', 'core/modules/views') (Line: 348)
Drupal\Core\Theme\Registry->Drupal\Core\Theme\{closure}(Object, 'views') (Line: 388)
Drupal\Core\Extension\ModuleHandler->invokeAllWith('theme', Object) (Line: 349)
Drupal\Core\Theme\Registry->build() (Line: 247)
Drupal\Core\Theme\Registry->get() (Line: 88)
Drupal\Core\Utility\ThemeRegistry->initializeRegistry() (Line: 69)
Drupal\Core\Utility\ThemeRegistry->__construct('theme_registry:runtime:opa_theme', Object, Object, Array, 1) (Line: 267)
Drupal\Core\Theme\Registry->getRuntime() (Line: 193)
Drupal\Core\Entity\EntityViewBuilder->getBuildDefaults(Object, 'full') (Line: 61)
Drupal\node\NodeViewBuilder->getBuildDefaults(Object, 'full') (Line: 157)
Drupal\Core\Entity\EntityViewBuilder->viewMultiple(Array, 'full', NULL) (Line: 123)
Drupal\Core\Entity\EntityViewBuilder->view(Object, 'full') (Line: 134)
Drupal\Core\Entity\Controller\EntityViewController->view(Object, 'full') (Line: 66)
Drupal\node\Controller\NodeViewController->view(Object, 'full', NULL)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 592)
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: 182)
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: 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: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

When I run the db updates I get the same error on the block_content_post_update_move_custom_block_library task.

The following db updates worked fine:

Update started: block_content_update_10100
Added revision routes to Content block entity type.
Update completed: block_content_update_10100
Update started: system_update_10100
Update completed: system_update_10100
Update started: block_content_update_10200
Update completed: block_content_update_10200
Update started: history_update_10100
Update completed: history_update_10100
Update started: block_content_post_update_block_library_view_permission
Update completed: block_content_post_update_block_library_view_permission

When I set a debug point at EntityViewsData line 333:

$this->mapFieldDefinition($table, $field_name, $field_definitions[$field_name], $table_mapping, $data[$table]);

It throws an exception on field_name: parent. See attached sceenshot of xdebug screen.

The fifth argument $data[$table], which is $data['taxonomy_term__parent'], is NULL

πŸ› Bug report
Status

Postponed: needs info

Version

11.0 πŸ”₯

Component
ViewsΒ  β†’

Last updated about 12 hours ago

Created by

πŸ‡ΊπŸ‡ΈUnited States mizage@gmail.com

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.

  • Issue created by @mizage@gmail.com
  • Status changed to Postponed: needs info about 1 year ago
  • πŸ‡³πŸ‡±Netherlands Lendude Amsterdam

    Since this could point to a regression, I'm changing this to a bug

    The most likely culprit seems to be πŸ“Œ pointless if() block in EntityViewsData Fixed since that changed some of the logic building this data.

    @mizage@gmail.com do you happen to have some steps to reproduce this on a clean install of Drupal?

  • πŸ‡ΊπŸ‡ΈUnited States mizage@gmail.com

    I wish I did.

    Originally I migrated the site from 7.x to 9.x and then to 10.0.x a few months later. I'm wondering if something didn't migrate cleanly and I just never noticed an issue.

    Does this look like a problem with the structure of a database table?

  • πŸ‡³πŸ‡ΏNew Zealand Richarda253

    I'm getting the same error but it refers to a different line of EntityViewsData.php:-

    TypeError: Drupal\views\EntityViewsData::mapFieldDefinition(): Argument #3 ($field_definition) must be of type Drupal\Core\Field\FieldDefinitionInterface, null given, called in /var/www/hpets/drupal/web/core/modules/views/src/EntityViewsData.php on line 333 in Drupal\views\EntityViewsData->mapFieldDefinition() (line 435 of core/modules/views/src/EntityViewsData.php).

    Likewise, the site was upgraded from 7.x to 9.x and then 10.1.6

    The only error I found on the site before it went away was this warning on Reports > Field List

    Warning: Undefined array key "image" in Drupal\field_ui\FieldStorageConfigListBuilder->buildRow() (line 133 of core/modules/field_ui/src/FieldStorageConfigListBuilder.php).
        Warning: Trying to access array offset on value of type null in Drupal\field_ui\FieldStorageConfigListBuilder->buildRow() (line 133 of core/modules/field_ui/src/FieldStorageConfigListBuilder.php).
        Warning: Undefined array key "image" in Drupal\field_ui\FieldStorageConfigListBuilder->buildRow() (line 133 of core/modules/field_ui/src/FieldStorageConfigListBuilder.php).
        Warning: Trying to access array offset on value of type null in Drupal\field_ui\FieldStorageConfigListBuilder->buildRow() (line 133 of core/modules/field_ui/src/FieldStorageConfigListBuilder.php).

    I hit the link to check manually for an update and it turned to custard. I have another version of this site running 10.1.6 and apart from the warnings, it seems fine.

  • πŸ‡ΊπŸ‡ΈUnited States mizage@gmail.com

    After updating from 10.1.0 to 10.1.6 the error has gone away and I was able to apply db updates cleanly.
    I did use this patch:

    https://www.drupal.org/files/issues/2023-11-10/FilterPluginBase.patch β†’

  • πŸ‡ΊπŸ‡ΈUnited States smethawee

    @mizag,

    This patch not working for me. It is the same issue.

  • πŸ‡¦πŸ‡«Afghanistan ab.shakir

    I'm facing this in Drupal 10.3.0 after upgrading from 9.5.11. The patch mentioned in #7 not helping in my case.

  • πŸ‡¦πŸ‡«Afghanistan ab.shakir

    For me it was one of the core patches which I previously applied for D9 version. After removing all patches for Drupal core, the issue is resolved now.

  • πŸ‡«πŸ‡·France sΓ©bastien-fr Nantes - France

    Hello,

    I had the same problem after an update to drupal 10.

    For me, the problem does not come from the view but from an entity so I had to find which one. In my case, it was an entity created by a module that was causing problems with drupal 10. I could not delete the entity after the update. So I restarted the site before the update, disabled the problematic module. An option allows you to delete the associated entity. I did the update again and it worked. My advice, do the update again starting from a backup, delete the problematic entities before the update.

Production build 0.71.5 2024