Call to a member function getId() on null in Drupal\Core\Entity\EntityViewBuilder->getBuildDefaults(

Created on 28 July 2022, over 2 years ago
Updated 25 June 2024, 6 months ago

Problem/Motivation

After remove german language i get this error.
I deleted all german term and german content but error persist.

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

Drupal\Core\Entity\EntityViewBuilder->getBuildDefaults(Object, 'teaser') (Line: 157)
Drupal\Core\Entity\EntityViewBuilder->viewMultiple(Array, 'teaser', 'de') (Line: 123)
Drupal\Core\Entity\EntityViewBuilder->view(Object, 'teaser', 'de') (Line: 89)
Drupal\views\Entity\Render\TranslationLanguageRenderer->preRender(Array) (Line: 221)
Drupal\views\Plugin\views\row\EntityRow->preRender(Array) (Line: 441)
Drupal\views\Plugin\views\style\StylePluginBase->preRender(Array) (Line: 1508)
Drupal\views\ViewExecutable->render() (Line: 131)
Drupal\views\Plugin\views\display\Block->execute() (Line: 1630)
Drupal\views\ViewExecutable->executeDisplay('block_1', Array) (Line: 81)
Drupal\views\Element\View::preRenderViewElement(Array) (Line: 59)
Drupal\views\Plugin\Block\ViewsBlock->build() (Line: 171)
Drupal\block\BlockViewBuilder::preRender(Array)
call_user_func_array(Array, Array) (Line: 101)
Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_render callbacks must be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was %s. See https://www.drupal.org/node/2966725', 'exception', 'Drupal\Core\Render\Element\RenderCallbackInterface') (Line: 772)
Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array) (Line: 363)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 435)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 201)
Drupal\Core\Render\Renderer->render(Array) (Line: 479)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 134)
__TwigTemplate_fd2d1d267a30195197ffb681dc27b97718ad79fc4f795dba55b6dfa6c57a9d9a->doDisplay(Array, Array) (Line: 405)
Twig\Template->displayWithErrorHandling(Array, Array) (Line: 378)
Twig\Template->display(Array, Array) (Line: 45)
__TwigTemplate_38dcf7bd64040a1d76d94890afe021edb563871c3dca59e6b1d00a67e4672ab5->doDisplay(Array, Array) (Line: 405)
Twig\Template->displayWithErrorHandling(Array, Array) (Line: 378)
Twig\Template->display(Array) (Line: 390)
Twig\Template->render(Array) (Line: 55)
twig_render_template('themes/custom/oto_frontend/templates/layout/page--taxonomy--product-term.html.twig', Array) (Line: 384)
Drupal\Core\Theme\ThemeManager->render('page', Array) (Line: 422)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 201)
Drupal\Core\Render\Renderer->render(Array) (Line: 479)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 113)
__TwigTemplate_184af407217c790cf11d0eb4944ff42ffc946b44f25c292c2ba1218346ab1814->doDisplay(Array, Array) (Line: 405)
Twig\Template->displayWithErrorHandling(Array, Array) (Line: 378)
Twig\Template->display(Array) (Line: 390)
Twig\Template->render(Array) (Line: 55)
twig_render_template('themes/custom/customer_frontend/templates/layout/html.html.twig', Array) (Line: 384)
Drupal\Core\Theme\ThemeManager->render('html', Array) (Line: 422)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 201)
Drupal\Core\Render\Renderer->render(Array) (Line: 162)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 564)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 163)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
call_user_func(Array, Object, 'kernel.view', Object) (Line: 142)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.view') (Line: 163)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 80)
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: 130)
Drupal\cdn\StackMiddleware\DuplicateContentPreventionMiddleware->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)


Steps to reproduce

Delete a language and got to taxonomy term views

🐛 Bug report
Status

Active

Version

11.0 🔥

Component
Taxonomy 

Last updated 2 days ago

  • Maintained by
  • 🇺🇸United States @xjm
  • 🇬🇧United Kingdom @catch
Created by

🇮🇹Italy trickfun

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.

  • 🇮🇳India Rahulmon Johnson Cochin

    This is due to the missing if condition to check if the entity has the isDefaultTranslation() function

    if ($entity->isDefaultTranslation()) { 
        //
    }
    
  • 🇮🇳India prashant.c Dharamshala

    I tried it locally and with the following steps and did NOT encounter any such error, may be steps to reproduce could help.

    • 2 languages "English" and other one is "Africaans"
    • Kept the english as a default language
    • Created 2 nodes one with each lanague
    • Deleted the "Africaans" language from /admin/config/regional/language
Production build 0.71.5 2024