Fatal error on url /admin/structure/block/block-content : Call to a member function getId() on null in ..EntityViewDisplay->buildMultiple() line 254 of ...EntityViewDisplay.php

Created on 19 October 2017, about 7 years ago
Updated 23 September 2023, about 1 year ago

Hello! I like D8, but after 1.5 year of use my website displays error when I visit user blocks:

The website encountered an unexpected error. Please try again later.

After enabling 'Database Logging' module and switching on errors reporting on it's configuration page the error become more specific:

The website encountered an unexpected error. Please try again later.
Error: Call to a member function getId() on null in Drupal\Core\Entity\Entity\EntityViewDisplay->buildMultiple() (line 254 of core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php).

Drupal\Core\Entity\Entity\EntityViewDisplay->buildMultiple(Array) (Line: 238)
Drupal\views\Entity\Render\EntityFieldRenderer->buildFields(Array) (Line: 125)
Drupal\views\Entity\Render\EntityFieldRenderer->render(Object, Object) (Line: 819)
Drupal\views\Plugin\views\field\EntityField->getItems(Object) (Line: 1137)
Drupal\views\Plugin\views\field\FieldPluginBase->advancedRender(Object) (Line: 224)
template_preprocess_views_view_field(Array, 'views_view_field', Array) (Line: 287)
Drupal\Core\Theme\ThemeManager->render('views_view_field', Array) (Line: 437)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer->render(Array) (Line: 1736)
Drupal\views\Plugin\views\field\FieldPluginBase->theme(Object) (Line: 761)
Drupal\views\Plugin\views\style\StylePluginBase->elementPreRenderRow(Array)
call_user_func(Array, Array) (Line: 378)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer->render(Array) (Line: 709)
Drupal\views\Plugin\views\style\StylePluginBase->renderFields(Array) (Line: 576)
Drupal\views\Plugin\views\style\StylePluginBase->renderGrouping(Array, Array, 1) (Line: 468)
Drupal\views\Plugin\views\style\StylePluginBase->render(Array) (Line: 2113)
Drupal\views\Plugin\views\display\DisplayPluginBase->render() (Line: 1531)
Drupal\views\ViewExecutable->render() (Line: 171)
Drupal\views\Plugin\views\display\Page->execute() (Line: 1628)
Drupal\views\ViewExecutable->executeDisplay('page_1', Array) (Line: 78)
Drupal\views\Element\View::preRenderViewElement(Array)
call_user_func(Array, Array) (Line: 378)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer->render(Array, ) (Line: 226)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 576)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 227)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 117)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object) (Line: 108)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.view', Object) (Line: 158)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 657)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Please, how to fix?

🐛 Bug report
Status

Closed: duplicate

Version

8.6 ⚰️

Component
Views 

Last updated 2 days ago

Created by

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.

  • 🇫🇮Finland lduerig

    #17 worked here, too! Thank you!

  • 🇱🇧Lebanon vitch

    This issue should not have been closed #13 is incorrect in stating that the other issue is a duplicate that proposes the proper solution. The discussion in the referenced presumed duplicate is about how to prevent this issue from happening in the future. People that such as myself reach this issue are usually seeking a solution to restore a wrecked instance.

    #17 is a viable temporary workaround after which the views that would have been altered loose the ability to filter by language since they will only display content in the current site language. (an alterative to site language could be content default translation which is even more limiting in terms of being able to display content in the required language)

    #8 proposes a database cleanup (which is the real solution to restore a Drupal instance to a properly functioning state) however the tables listed are far from exhaustive. I have attempted a more radical cleanup where i delete from all tables that have a langcode column all the entries that still have the langcode for the deleted language(s). This did fix the issue on the unaltered content listing views. (I am not sure however that this indiscriminate deletion did not break anything else).

    A safer but possibly daunting solution would be to recreate the deleted languages (the langcode must be the same). This will restore all the views which can then be used to identify content in the languages that we want to delete and manually delete the translations before deleting the language again.

Production build 0.71.5 2024