Created on 25 March 2023, over 1 year ago
Updated 12 July 2024, 4 months ago

Problem/Motivation

php error:

TypeError: method_exists(): Argument #1 ($object_or_class) must be of type object|string, null given in method_exists() (line 49 in /var/www/vhosts/example.com/httpdocs/example.com/modules/twig_render_this/src/TwigExtension/RenderThis.php)
#0 /var/www/vhosts/example.com/httpdocs/example.com/modules/twig_render_this/src/TwigExtension/RenderThis.php(49): method_exists()
#1 /var/www/vhosts/example.com/httpdocs/example.com/sites/default/files/php/twig/641f33a0e8f38_page.html.twig_i1RJi1Ybh16jaWwK9taCBKStj/US9Y9vDniq43LYStRAzn8yvcwQGgF39x7_SKuJFQizM.php(57): Drupal\twig_render_this\TwigExtension\RenderThis::renderThisFilter()
#2 /var/www/vhosts/example.com/httpdocs/example.com/vendor/twig/twig/src/Template.php(405): __TwigTemplate_de8f36eb4a21037a02e311a1d05e62cf->doDisplay()
#3 /var/www/vhosts/example.com/httpdocs/example.com/vendor/twig/twig/src/Template.php(378): Twig\Template->displayWithErrorHandling()
#4 /var/www/vhosts/example.com/httpdocs/example.com/vendor/twig/twig/src/Template.php(390): Twig\Template->display()
#5 /var/www/vhosts/example.com/httpdocs/example.com/core/themes/engines/twig/twig.engine(55): Twig\Template->render()
#6 /var/www/vhosts/example.com/httpdocs/example.com/core/lib/Drupal/Core/Theme/ThemeManager.php(384): twig_render_template()
#7 /var/www/vhosts/example.com/httpdocs/example.com/core/lib/Drupal/Core/Render/Renderer.php(433): Drupal\Core\Theme\ThemeManager->render()
#8 /var/www/vhosts/example.com/httpdocs/example.com/core/lib/Drupal/Core/Render/Renderer.php(204): Drupal\Core\Render\Renderer->doRender()
#9 /var/www/vhosts/example.com/httpdocs/example.com/core/lib/Drupal/Core/Template/TwigExtension.php(479): Drupal\Core\Render\Renderer->render()
#10 /var/www/vhosts/example.com/httpdocs/example.com/sites/default/files/php/twig/641f33a0e8f38_html.html.twig_jBfuIBNC-T63wJDpY3FSTm38k/Qg_mGFfDujz2WUs2woG_nnZBYkZxcAVqotxrnyElPDo.php(98): Drupal\Core\Template\TwigExtension->escapeFilter()
#11 /var/www/vhosts/example.com/httpdocs/example.com/vendor/twig/twig/src/Template.php(405): __TwigTemplate_255c985757caafe72f62a3421c67e1d8->doDisplay()
#12 /var/www/vhosts/example.com/httpdocs/example.com/vendor/twig/twig/src/Template.php(378): Twig\Template->displayWithErrorHandling()
#13 /var/www/vhosts/example.com/httpdocs/example.com/vendor/twig/twig/src/Template.php(390): Twig\Template->display()
#14 /var/www/vhosts/example.com/httpdocs/example.com/core/themes/engines/twig/twig.engine(55): Twig\Template->render()
#15 /var/www/vhosts/example.com/httpdocs/example.com/core/lib/Drupal/Core/Theme/ThemeManager.php(384): twig_render_template()
#16 /var/www/vhosts/example.com/httpdocs/example.com/core/lib/Drupal/Core/Render/Renderer.php(433): Drupal\Core\Theme\ThemeManager->render()
#17 /var/www/vhosts/example.com/httpdocs/example.com/core/lib/Drupal/Core/Render/Renderer.php(204): Drupal\Core\Render\Renderer->doRender()
#18 /var/www/vhosts/example.com/httpdocs/example.com/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(162): Drupal\Core\Render\Renderer->render()
#19 /var/www/vhosts/example.com/httpdocs/example.com/core/lib/Drupal/Core/Render/Renderer.php(580): Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}()
#20 /var/www/vhosts/example.com/httpdocs/example.com/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(163): Drupal\Core\Render\Renderer->executeInRenderContext()
#21 /var/www/vhosts/example.com/httpdocs/example.com/core/lib/Drupal/Core/EventSubscriber/MainContentViewSubscriber.php(90): Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse()
#22 [internal function]: Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray()
#23 /var/www/vhosts/example.com/httpdocs/example.com/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(142): call_user_func()
#24 /var/www/vhosts/example.com/httpdocs/example.com/vendor/symfony/http-kernel/HttpKernel.php(174): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch()
#25 /var/www/vhosts/example.com/httpdocs/example.com/vendor/symfony/http-kernel/HttpKernel.php(81): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
#26 /var/www/vhosts/example.com/httpdocs/example.com/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle()
#27 /var/www/vhosts/example.com/httpdocs/example.com/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle()
#28 /var/www/vhosts/example.com/httpdocs/example.com/core/modules/page_cache/src/StackMiddleware/PageCache.php(191): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
#29 /var/www/vhosts/example.com/httpdocs/example.com/core/modules/page_cache/src/StackMiddleware/PageCache.php(128): Drupal\page_cache\StackMiddleware\PageCache->fetch()
#30 /var/www/vhosts/example.com/httpdocs/example.com/core/modules/page_cache/src/StackMiddleware/PageCache.php(82): Drupal\page_cache\StackMiddleware\PageCache->lookup()
#31 /var/www/vhosts/example.com/httpdocs/example.com/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle()
#32 /var/www/vhosts/example.com/httpdocs/example.com/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
#33 /var/www/vhosts/example.com/httpdocs/example.com/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
#34 /var/www/vhosts/example.com/httpdocs/example.com/core/lib/Drupal/Core/DrupalKernel.php(718): Stack\StackedHttpKernel->handle()
#35 /var/www/vhosts/example.com/httpdocs/example.com/index.php(19): Drupal\Core\DrupalKernel->handle()
#36 {main}

Steps to reproduce

drupal 9.5.7
Twig Render This 8.x-1.08

Proposed resolution

Uncommenting the elseif-routine on line 47 is a first aid.

🐛 Bug report
Status

Closed: works as designed

Version

1.8

Component

Code

Created by

🇩🇪Germany Umac_de

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

Comments & Activities

  • Issue created by @Umac_de
  • 🇩🇪Germany Umac_de

    Still had the problem with 10.2.7 and 2.0.0

    My solution is in twig_render_this/src/TwigExtension/RenderThis.php >> 49

    elseif ($content !== NULL && ($content instanceof FieldItemInterface ||
          $content instanceof FieldItemListInterface ||
          method_exists($content, 'view'))
        ) {
  • Status changed to Needs review 5 months ago
  • 🇮🇳India Rajan Kumar@2026

    Hii Umac_de

    I have fixed the issue and created a patch. Thanks!

  • Assigned to gnikolovski
  • Status changed to Closed: works as designed 4 months ago
  • 🇷🇸Serbia gnikolovski Subotica, Serbia

    Version 8.x is not compatible with Drupal 10.

    Please use version 2.0.x

Production build 0.71.5 2024