0

Using Drupal 8.8.0, multilingual, on localhost (Windows 10, PHP 7.3.12).

I have a fatal error on the admin/content page, but only if I use certain options for sorting or filtering the results.

Available filters:

  • title: works fine
  • content type: fatal error
  • published status: works fine
  • language: works fine

Available sorting options:

  • title: fatal error
  • content type: fatal error
  • author: fatal error
  • status (published/not): works fine
  • updated: works fine
  • created: works fine

However if a filter is in use (and hasn't caused a crash), then all sorting options work fine, as far as I can tell.

When checking the server log, I find the following error:

Error: Call to a member function getId() on null in C:\\htdocs\\myproject\\www\\core\\lib\\Drupal\\Core\\Entity\\Entity\\EntityViewDisplay.php on line 258 #0 C:\\htdocs\\myproject\\www\\core\\modules\\views\\src\\Entity\\Render\\EntityFieldRenderer.php(276): Drupal\\Core\\Entity\\Entity\\EntityViewDisplay->buildMultiple(Array), referer: http://localhost/myproject/www/fr/admin/content
#1 C:\\htdocs\\myproject\\www\\core\\modules\\views\\src\\Entity\\Render\\EntityFieldRenderer.php(163): Drupal\\views\\Entity\\Render\\EntityFieldRenderer->buildFields(Array), referer: http://localhost/myproject/www/fr/admin/content
#2 C:\\htdocs\\myproject\\www\\core\\modules\\views\\src\\Plugin\\views\\field\\EntityField.php(846): Drupal\\views\\Entity\\Render\\EntityFieldRenderer->render(Object(Drupal\\views\\ResultRow), Object(Drupal\\views\\Plugin\\views\\field\\EntityField)), referer: http://localhost/myproject/www/fr/admin/content
#3 C:\\htdocs\\myproject\\www\\core\\modules\\views\\src\\Plugin\\views\\field\\FieldPluginBase.php(1148): Drupal\\views\\Plugin\\views\\field\\EntityField->getItems(Object(Drupal\\views\\ResultRow)), referer: http://localhost/myproject/www/fr/admin/content
#4 C:\\htdocs\\myproject\\www\\core\\modules\\views\\views.theme.inc(236): Drupal\\views\\Plugin\\views\\field\\FieldPluginBase->advancedRender(Object(Drupal\\views\\ResultRow)), referer: http://localhost/myproject/www/fr/admin/content
#5 C:\\htdocs\\myproject\\www\\core\\lib\\Drupal\\Core\\Theme\\ThemeManager.php(287): template_preprocess_views_view_field(Array, 'views_view_fiel...', Array), referer: http://localhost/myproject/www/fr/admin/content
#6 C:\\htdocs\\myproject\\www\\core\\lib\\Drupal\\Core\\Render\\Renderer.php(431): Drupal\\Core\\Theme\\ThemeManager->render('views_view_fiel...', Array), referer: http://localhost/myproject/www/fr/admin/content
#7 C:\\htdocs\\myproject\\www\\core\\lib\\Drupal\\Core\\Render\\Renderer.php(200): Drupal\\Core\\Render\\Renderer->doRender(Array, false), referer: http://localhost/myproject/www/fr/admin/content
#8 C:\\htdocs\\myproject\\www\\core\\modules\\views\\src\\Plugin\\views\\field\\FieldPluginBase.php(1747): Drupal\\Core\\Render\\Renderer->render(Array), referer: http://localhost/myproject/www/fr/admin/content
#9 C:\\htdocs\\myproject\\www\\core\\modules\\views\\src\\Plugin\\views\\style\\StylePluginBase.php(770): Drupal\\views\\Plugin\\views\\field\\FieldPluginBase->theme(Object(Drupal\\views\\ResultRow)), referer: http://localhost/myproject/www/fr/admin/content
#10 [internal function]: Drupal\\views\\Plugin\\views\\style\\StylePluginBase->elementPreRenderRow(Array), referer: http://localhost/myproject/www/fr/admin/content
#11 C:\\htdocs\\myproject\\www\\core\\lib\\Drupal\\Core\\Security\\DoTrustedCallbackTrait.php(100): call_user_func_array(Array, Array), referer: http://localhost/myproject/www/fr/admin/content
#12 C:\\htdocs\\myproject\\www\\core\\lib\\Drupal\\Core\\Render\\Renderer.php(781): Drupal\\Core\\Render\\Renderer->doTrustedCallback(Array, Array, 'Render #pre_ren...', 'silenced_deprec...', 'Drupal\\\\Core\\\\Ren...'), referer: http://localhost/myproject/www/fr/admin/content
#13 C:\\htdocs\\myproject\\www\\core\\lib\\Drupal\\Core\\Render\\Renderer.php(372): Drupal\\Core\\Render\\Renderer->doCallback('#pre_render', Array, Array), referer: http://localhost/myproject/www/fr/admin/content
#14 C:\\htdocs\\myproject\\www\\core\\lib\\Drupal\\Core\\Render\\Renderer.php(200): Drupal\\Core\\Render\\Renderer->doRender(Array, false), referer: http://localhost/myproject/www/fr/admin/content
#15 C:\\htdocs\\myproject\\www\\core\\modules\\views\\src\\Plugin\\views\\style\\StylePluginBase.php(709): Drupal\\Core\\Render\\Renderer->render(Array), referer: http://localhost/myproject/www/fr/admin/content
#16 C:\\htdocs\\myproject\\www\\core\\modules\\views\\src\\Plugin\\views\\style\\StylePluginBase.php(576): Drupal\\views\\Plugin\\views\\style\\StylePluginBase->renderFields(Array), referer: http://localhost/myproject/www/fr/admin/content
#17 C:\\htdocs\\myproject\\www\\core\\modules\\views\\src\\Plugin\\views\\style\\StylePluginBase.php(468): Drupal\\views\\Plugin\\views\\style\\StylePluginBase->renderGrouping(Array, Array, true), referer: http://localhost/myproject/www/fr/admin/content
#18 C:\\htdocs\\myproject\\www\\core\\modules\\views\\src\\Plugin\\views\\display\\DisplayPluginBase.php(2140): Drupal\\views\\Plugin\\views\\style\\StylePluginBase->render(Array), referer: http://localhost/myproject/www/fr/admin/content
#19 C:\\htdocs\\myproject\\www\\core\\modules\\views\\src\\ViewExecutable.php(1533): Drupal\\views\\Plugin\\views\\display\\DisplayPluginBase->render(), referer: http://localhost/myproject/www/fr/admin/content
#20 C:\\htdocs\\myproject\\www\\core\\modules\\views\\src\\Plugin\\views\\display\\Page.php(183): Drupal\\views\\ViewExecutable->render(), referer: http://localhost/myproject/www/fr/admin/content
#21 C:\\htdocs\\myproject\\www\\core\\modules\\views\\src\\ViewExecutable.php(1630): Drupal\\views\\Plugin\\views\\display\\Page->execute(), referer: http://localhost/myproject/www/fr/admin/content
#22 C:\\htdocs\\myproject\\www\\core\\modules\\views\\src\\Element\\View.php(77): Drupal\\views\\ViewExecutable->executeDisplay('page_1', Array), referer: http://localhost/myproject/www/fr/admin/content
#23 [internal function]: Drupal\\views\\Element\\View::preRenderViewElement(Array), referer: http://localhost/myproject/www/fr/admin/content
#24 C:\\htdocs\\myproject\\www\\core\\lib\\Drupal\\Core\\Security\\DoTrustedCallbackTrait.php(100): call_user_func_array(Array, Array), referer: http://localhost/myproject/www/fr/admin/content
#25 C:\\htdocs\\myproject\\www\\core\\lib\\Drupal\\Core\\Render\\Renderer.php(781): Drupal\\Core\\Render\\Renderer->doTrustedCallback(Array, Array, 'Render #pre_ren...', 'silenced_deprec...', 'Drupal\\\\Core\\\\Ren...'), referer: http://localhost/myproject/www/fr/admin/content
#26 C:\\htdocs\\myproject\\www\\core\\lib\\Drupal\\Core\\Render\\Renderer.php(372): Drupal\\Core\\Render\\Renderer->doCallback('#pre_render', Array, Array), referer: http://localhost/myproject/www/fr/admin/content
#27 C:\\htdocs\\myproject\\www\\core\\lib\\Drupal\\Core\\Render\\Renderer.php(200): Drupal\\Core\\Render\\Renderer->doRender(Array, false), referer: http://localhost/myproject/www/fr/admin/content
#28 C:\\htdocs\\myproject\\www\\core\\lib\\Drupal\\Core\\Render\\MainContent\\HtmlRenderer.php(226): Drupal\\Core\\Render\\Renderer->render(Array, false), referer: http://localhost/myproject/www/fr/admin/content
#29 C:\\htdocs\\myproject\\www\\core\\lib\\Drupal\\Core\\Render\\Renderer.php(573): Drupal\\Core\\Render\\MainContent\\HtmlRenderer->Drupal\\Core\\Render\\MainContent\\{closure}(), referer: http://localhost/myproject/www/fr/admin/content
#30 C:\\htdocs\\myproject\\www\\core\\lib\\Drupal\\Core\\Render\\MainContent\\HtmlRenderer.php(227): Drupal\\Core\\Render\\Renderer->executeInRenderContext(Object(Drupal\\Core\\Render\\RenderContext), Object(Closure)), referer: http://localhost/myproject/www/fr/admin/content
#31 C:\\htdocs\\myproject\\www\\core\\lib\\Drupal\\Core\\Render\\MainContent\\HtmlRenderer.php(117): Drupal\\Core\\Render\\MainContent\\HtmlRenderer->prepare(Array, Object(Symfony\\Component\\HttpFoundation\\Request), Object(Drupal\\Core\\Routing\\CurrentRouteMatch)), referer: http://localhost/myproject/www/fr/admin/content
#32 C:\\htdocs\\myproject\\www\\core\\lib\\Drupal\\Core\\EventSubscriber\\MainContentViewSubscriber.php(90): Drupal\\Core\\Render\\MainContent\\HtmlRenderer->renderResponse(Array, Object(Symfony\\Component\\HttpFoundation\\Request), Object(Drupal\\Core\\Routing\\CurrentRouteMatch)), referer: http://localhost/myproject/www/fr/admin/content
#33 [internal function]: Drupal\\Core\\EventSubscriber\\MainContentViewSubscriber->onViewRenderArray(Object(Symfony\\Component\\HttpKernel\\Event\\GetResponseForControllerResultEvent), 'kernel.view', Object(Drupal\\Component\\EventDispatcher\\ContainerAwareEventDispatcher)), referer: http://localhost/myproject/www/fr/admin/content
#34 C:\\htdocs\\myproject\\www\\core\\lib\\Drupal\\Component\\EventDispatcher\\ContainerAwareEventDispatcher.php(111): call_user_func(Array, Object(Symfony\\Component\\HttpKernel\\Event\\GetResponseForControllerResultEvent), 'kernel.view', Object(Drupal\\Component\\EventDispatcher\\ContainerAwareEventDispatcher)), referer: http://localhost/myproject/www/fr/admin/content
#35 C:\\htdocs\\myproject\\www\\vendor\\symfony\\http-kernel\\HttpKernel.php(156): Drupal\\Component\\EventDispatcher\\ContainerAwareEventDispatcher->dispatch('kernel.view', Object(Symfony\\Component\\HttpKernel\\Event\\GetResponseForControllerResultEvent)), referer: http://localhost/myproject/www/fr/admin/content
#36 C:\\htdocs\\myproject\\www\\vendor\\symfony\\http-kernel\\HttpKernel.php(68): Symfony\\Component\\HttpKernel\\HttpKernel->handleRaw(Object(Symfony\\Component\\HttpFoundation\\Request), 1), referer: http://localhost/myproject/www/fr/admin/content
#37 C:\\htdocs\\myproject\\www\\core\\lib\\Drupal\\Core\\StackMiddleware\\Session.php(57): Symfony\\Component\\HttpKernel\\HttpKernel->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true), referer: http://localhost/myproject/www/fr/admin/content
#38 C:\\htdocs\\myproject\\www\\core\\lib\\Drupal\\Core\\StackMiddleware\\KernelPreHandle.php(47): Drupal\\Core\\StackMiddleware\\Session->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true), referer: http://localhost/myproject/www/fr/admin/content
#39 C:\\htdocs\\myproject\\www\\core\\modules\\page_cache\\src\\StackMiddleware\\PageCache.php(106): Drupal\\Core\\StackMiddleware\\KernelPreHandle->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true), referer: http://localhost/myproject/www/fr/admin/content
#40 C:\\htdocs\\myproject\\www\\core\\modules\\page_cache\\src\\StackMiddleware\\PageCache.php(85): Drupal\\page_cache\\StackMiddleware\\PageCache->pass(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true), referer: http://localhost/myproject/www/fr/admin/content
#41 C:\\htdocs\\myproject\\www\\core\\lib\\Drupal\\Core\\StackMiddleware\\ReverseProxyMiddleware.php(47): Drupal\\page_cache\\StackMiddleware\\PageCache->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true), referer: http://localhost/myproject/www/fr/admin/content
#42 C:\\htdocs\\myproject\\www\\core\\lib\\Drupal\\Core\\StackMiddleware\\NegotiationMiddleware.php(52): Drupal\\Core\\StackMiddleware\\ReverseProxyMiddleware->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true), referer: http://localhost/myproject/www/fr/admin/content
#43 C:\\htdocs\\myproject\\www\\vendor\\stack\\builder\\src\\Stack\\StackedHttpKernel.php(23): Drupal\\Core\\StackMiddleware\\NegotiationMiddleware->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true), referer: http://localhost/myproject/www/fr/admin/content
#44 C:\\htdocs\\myproject\\www\\core\\lib\\Drupal\\Core\\DrupalKernel.php(694): Stack\\StackedHttpKernel->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, tru, referer: http://localhost/myproject/www/fr/admin/content

(Every line starting with [Fri Dec 06 19:26:08.993106 2019] [fcgid:warn] [pid 16812:tid 1200] [client ::1:64229] mod_fcgid: stderr:)

Can anybody help identify what is causing this error? Thanks in advance.

1 Answer 1

0

I got a similar error on another (custom) views page and it helped me understand the cause of this error. This time, the full error was:

Error: Call to a member function getId() on null in Drupal\Core\Entity\EntityViewBuilder->getBuildDefaults() (line 223 of C:\htdocs\myproject\www\core\lib\Drupal\Core\Entity\EntityViewBuilder.php) #0 C:\htdocs\myproject\www\core\modules\node\src\NodeViewBuilder.php(61): Drupal\Core\Entity\EntityViewBuilder->getBuildDefaults(Object(Drupal\node\Entity\Node), 'teaser')
#1 C:\htdocs\myproject\www\core\lib\Drupal\Core\Entity\EntityViewBuilder.php(168): Drupal\node\NodeViewBuilder->getBuildDefaults(Object(Drupal\node\Entity\Node), 'teaser')
#2 C:\htdocs\myproject\www\core\lib\Drupal\Core\Entity\EntityViewBuilder.php(134): Drupal\Core\Entity\EntityViewBuilder->viewMultiple(Array, 'teaser', 'es')
#3 C:\htdocs\myproject\www\core\modules\views\src\Entity\Render\TranslationLanguageRenderer.php(90): Drupal\Core\Entity\EntityViewBuilder->view(Object(Drupal\node\Entity\Node), 'teaser', 'es')
#4 C:\htdocs\myproject\www\core\modules\views\src\Plugin\views\row\EntityRow.php(247): Drupal\views\Entity\Render\TranslationLanguageRenderer->preRender(Array)
#5 C:\htdocs\myproject\www\core\modules\views\src\Plugin\views\style\StylePluginBase.php(434): Drupal\views\Plugin\views\row\EntityRow->preRender(Array)
#6 C:\htdocs\myproject\www\core\modules\views\src\ViewExecutable.php(1508): Drupal\views\Plugin\views\style\StylePluginBase->preRender(Array)
#7 C:\htdocs\myproject\www\core\modules\views\src\Plugin\views\display\Page.php(183): Drupal\views\ViewExecutable->render()
#8 C:\htdocs\myproject\www\core\modules\views\src\ViewExecutable.php(1630): Drupal\views\Plugin\views\display\Page->execute()
#9 C:\htdocs\myproject\www\core\modules\views\src\Element\View.php(77): Drupal\views\ViewExecutable->executeDisplay('page_2', Array)
#10 [internal function]: Drupal\views\Element\View::preRenderViewElement(Array)
#11 C:\htdocs\myproject\www\core\lib\Drupal\Core\Security\DoTrustedCallbackTrait.php(100): call_user_func_array(Array, Array)
#12 C:\htdocs\myproject\www\core\lib\Drupal\Core\Render\Renderer.php(781): Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_ren...', 'silenced_deprec...', 'Drupal\\Core\\Ren...')
#13 C:\htdocs\myproject\www\core\lib\Drupal\Core\Render\Renderer.php(372): Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array)
#14 C:\htdocs\myproject\www\core\lib\Drupal\Core\Render\Renderer.php(200): Drupal\Core\Render\Renderer->doRender(Array, false)
#15 C:\htdocs\myproject\www\core\lib\Drupal\Core\Render\MainContent\HtmlRenderer.php(226): Drupal\Core\Render\Renderer->render(Array, false)
#16 C:\htdocs\myproject\www\core\lib\Drupal\Core\Render\Renderer.php(573): Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}()
#17 C:\htdocs\myproject\www\core\lib\Drupal\Core\Render\MainContent\HtmlRenderer.php(227): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#18 C:\htdocs\myproject\www\core\lib\Drupal\Core\Render\MainContent\HtmlRenderer.php(117): Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\CurrentRouteMatch))
#19 C:\htdocs\myproject\www\core\lib\Drupal\Core\EventSubscriber\MainContentViewSubscriber.php(90): Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\CurrentRouteMatch))
#20 [internal function]: Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object(Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent), 'kernel.view', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#21 C:\htdocs\myproject\www\core\lib\Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher.php(111): call_user_func(Array, Object(Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent), 'kernel.view', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#22 C:\htdocs\myproject\www\vendor\symfony\http-kernel\HttpKernel.php(156): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.view', Object(Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent))
#23 C:\htdocs\myproject\www\vendor\symfony\http-kernel\HttpKernel.php(68): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#24 C:\htdocs\myproject\www\core\lib\Drupal\Core\StackMiddleware\Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#25 C:\htdocs\myproject\www\core\lib\Drupal\Core\StackMiddleware\KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#26 C:\htdocs\myproject\www\core\modules\page_cache\src\StackMiddleware\PageCache.php(191): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#27 C:\htdocs\myproject\www\core\modules\page_cache\src\StackMiddleware\PageCache.php(128): Drupal\page_cache\StackMiddleware\PageCache->fetch(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#28 C:\htdocs\myproject\www\core\modules\page_cache\src\StackMiddleware\PageCache.php(82): Drupal\page_cache\StackMiddleware\PageCache->lookup(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#29 C:\htdocs\myproject\www\core\lib\Drupal\Core\StackMiddleware\ReverseProxyMiddleware.php(47): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#30 C:\htdocs\myproject\www\core\lib\Drupal\Core\StackMiddleware\NegotiationMiddleware.php(52): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#31 C:\htdocs\myproject\www\vendor\stack\builder\src\Stack\StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#32 C:\htdocs\myproject\www\core\lib\Drupal\Core\DrupalKernel.php(694): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#33 C:\htdocs\myproject\www\index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#34 {main}.

The part that caught my eye is on line #2: viewMultiple(Array, 'teaser', 'es')

Like I said, this is a multilingual site (it's actually an old D6 site that I'm currently migrating to D8). It used to have 5 languages for content, but at some point the client decided to drop 2 of those languages (Spanish and Italian). But there are still content entries for those languages in the Drupal database.

Up to this point, Drupal was still configured to use the 5 initial languages, but I recently decided to remove the two unused languages in order to simplify the UX. That's where the error started to appear (although I did not run into it immediately).

So in short, a view trying to display pieces of content in a language that is no longer present in Drupal will cause this error.

I added Spanish and Italian back in Drupal, and after that the error stopped occurring. I then deleted all contents in Italian and Spanish, then removed those languages from Drupal again: the error hasn't come back.

Problem solved as far as I can tell.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.