TypeError: term_body_class_get_terms(): Argument #1 ($entity) must be of type Drupal\Core\Entity\EntityInterface,

Created on 31 July 2024, 5 months ago
Updated 1 August 2024, 5 months ago

Problem/Motivation

When visiting a views argument page the following error happens

on page /node/%node/view-page

TypeError: term_body_class_get_terms(): Argument #1 ($entity) must be of type Drupal\Core\Entity\EntityInterface, string given, called in \modules\contrib\term_body_class\term_body_class.module on line 147 in term_body_class_get_terms() (line 168 of \modules\contrib\term_body_class\term_body_class.module).

The back trace

#0 \modules\contrib\term_body_class\term_body_class.module(147): term_body_class_get_terms('9')
#1 [internal function]: term_body_class_preprocess_html(Array, 'html', Array)
#2 \core\lib\Drupal\Core\Theme\ThemeManager.php(261): call_user_func_array('term_body_class...', Array)
#3 \core\lib\Drupal\Core\Render\Renderer.php(480): Drupal\Core\Theme\ThemeManager->render('html', Array)
#4 \core\lib\Drupal\Core\Render\Renderer.php(240): Drupal\Core\Render\Renderer->doRender(Array, false)
#5 \core\lib\Drupal\Core\Render\MainContent\HtmlRenderer.php(158): Drupal\Core\Render\Renderer->render(Array)
#6 \core\lib\Drupal\Core\Render\Renderer.php(627): Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}()
#7 \core\lib\Drupal\Core\Render\MainContent\HtmlRenderer.php(159): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#8 \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))
#9 [internal function]: Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object(Symfony\Component\HttpKernel\Event\ViewEvent), 'kernel.view', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#10 \core\lib\Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher.php(111): call_user_func(Array, Object(Symfony\Component\HttpKernel\Event\ViewEvent), 'kernel.view', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#11 C:\wamp64\www\sos3\vendor\symfony\http-kernel\HttpKernel.php(186): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object(Symfony\Component\HttpKernel\Event\ViewEvent), 'kernel.view')
#12 C:\wamp64\www\sos3\vendor\symfony\http-kernel\HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#13 \core\lib\Drupal\Core\StackMiddleware\Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#14 \core\lib\Drupal\Core\StackMiddleware\KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#15 \core\lib\Drupal\Core\StackMiddleware\ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#16 \core\modules\big_pipe\src\StackMiddleware\ContentLength.php(32): Drupal\Core\StackMiddleware\ContentLength->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#17 \core\modules\page_cache\src\StackMiddleware\PageCache.php(106): Drupal\big_pipe\StackMiddleware\ContentLength->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#18 \core\modules\page_cache\src\StackMiddleware\PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#19 \core\lib\Drupal\Core\StackMiddleware\ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#20 \core\lib\Drupal\Core\StackMiddleware\NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#21 \core\lib\Drupal\Core\StackMiddleware\AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#22 \core\lib\Drupal\Core\StackMiddleware\StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#23 \core\lib\Drupal\Core\DrupalKernel.php(704): Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#24 \index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#25 {main}

Steps to reproduce

Create a view with contectuial filter of (content:ID) and add a path like /node/%node/somepage
Visit the link and get the above error

This error does not happen on /node/%node/edit

🐛 Bug report
Status

RTBC

Version

1.0

Component

Code

Created by

🇿🇦South Africa vlooi vlerke

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

Comments & Activities

Production build 0.71.5 2024