Problem/Motivation
graphql_twig 8.x-1.0-beta16 with Drupal 8.9.10 produces an error on every page load:
Error: Call to undefined method __TwigTemplate_42534f1e1642e4f45ede9e87932f74e08e0f950a474ccaeafc9b35c41562920a::checkSecurity() in __TwigTemplate_42534f1e1642e4f45ede9e87932f74e08e0f950a474ccaeafc9b35c41562920a->__construct() (line 26 of /app/web/sites/default/files/php/twig/5fc77cd82c09f_views-view.html.twig_LoLin7Z3SA3xJTRywYMb0e8ud/2_I3lCViozvQ-LdG-AJJ8MQ24-n150Txp7lqufKb1pQ.php)
#0 /app/vendor/twig/twig/src/Environment.php(510): __TwigTemplate_42534f1e1642e4f45ede9e87932f74e08e0f950a474ccaeafc9b35c41562920a->__construct(Object(Drupal\graphql_twig\GraphQLTwigEnvironment))
#1 /app/vendor/twig/twig/src/Environment.php(445): Twig\Environment->loadClass('__TwigTemplate_...', 'core/themes/bar...', NULL)
#2 /app/web/core/themes/engines/twig/twig.engine(64): Twig\Environment->loadTemplate('core/themes/bar...')
#3 /app/web/core/lib/Drupal/Core/Theme/ThemeManager.php(384): twig_render_template('core/themes/bar...', Array)
#4 /app/web/core/lib/Drupal/Core/Render/Renderer.php(431): Drupal\Core\Theme\ThemeManager->render('views_view', Array)
#5 /app/web/core/lib/Drupal/Core/Render/Renderer.php(444): Drupal\Core\Render\Renderer->doRender(Array)
#6 /app/web/core/lib/Drupal/Core/Render/Renderer.php(200): Drupal\Core\Render\Renderer->doRender(Array, false)
#7 /app/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(226): Drupal\Core\Render\Renderer->render(Array, false)
#8 /app/web/core/lib/Drupal/Core/Render/Renderer.php(573): Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}()
#9 /app/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(227): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#10 /app/web/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))
#11 /app/web/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))
#12 [internal function]: Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object(Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent), 'kernel.view', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#13 /app/web/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))
#14 /app/vendor/symfony/http-kernel/HttpKernel.php(156): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.view', Object(Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent))
#15 /app/vendor/symfony/http-kernel/HttpKernel.php(68): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#16 /app/web/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#17 /app/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#18 /app/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#19 /app/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#20 /app/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#21 /app/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(52): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#22 /app/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#23 /app/web/core/lib/Drupal/Core/DrupalKernel.php(708): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#24 /app/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#25 {main}
.
Steps to reproduce
Use a vanilla Drupal 8 installation and add latest graphql_twig:
composer require drupal/graphql_twig
drush en graphql_twig -y
Visit any page in the frontend or admin theme.
Error does not occur if with a vanilla Drupal9 installation.
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | graphql_twig-3186005-9.patch | 772 bytes | olli |
Comments
Comment #2
Belialius commentedCan confirm that I have the same issue on Drupal 8.9.10
Comment #3
gaards commentedHaven't seen that error on our current site (Drupal 8.9.11), but maybe the error could be attributed to differences between themes or module usage between sites (Twig version should be the same, 1.42.5)? However we're seeing a similar error when trying to upgrade a site from Drupal 8.9 to Drupal 9.1, so there's definitely something that's not working okay (Twig version is updated to 2.14.1).
Here are some pointers that maybe could shed some light into this issue:
https://github.com/twigphp/Twig/issues/3411
https://github.com/twigphp/Twig/pull/3413
Comment #4
drupov commentedIn the mentioned vanilla Drupal installation the twig version is (according to vendor/twig/twig/CHANGELOG)
Drupal has been installed via composer, so with
composer create-project drupal-composer/drupal-project:8.x-dev drupal8 --stability dev --no-interactionPHP version is 7.3.25.
I haven't tried downgrading Twig to 1.42.5 yet, will post my finding on that later.
One last thing: I am using a very basic Lando recipe, but I don't think that is related.
Comment #5
gaards commentedInteresting, I would have expected it to stay at 1.42.5 as it is restricted to that version in the official Drupal repo: https://git.drupalcode.org/project/drupal/-/blob/8.9.x/composer.lock#L3926
It looks like that project/command allows Twig to be updated to the very latest version, while projects using the recommended package (
drupal/recommended-project) limits Twig to 1.42.5. This is how a Drupal project with the recommended package is installed according to the documentation:https://www.drupal.org/docs/develop/using-composer/using-composer-to-ins...
But we could be on to something, meaning the probable cause is a Twig update that has made it so that the current code in this module is incompatible (this would explain the problems with Drupal 9 upgrade we had with latest Twig 2, and you had with the latest version of Twig 1). The issue links I posted above seem to be very much relevant, but I'm still unsure what needs to change in this module to make it compatible.
Comment #6
gaards commentedI had another look at this on a fresh D9.1 site. I tried replacing all deprecated Twig classes in the module but the error is still present. I then tried to identify which part of the code causes the WSOD and found that commenting out the following line would remove the WSOD (but I expect this to break the module functionality):
https://git.drupalcode.org/project/graphql_twig/-/blob/8.x-1.x/src/Graph...
Comment #7
jellyburger commentedI have the same problem with Drupal 8.9.12.
Has anyone figured out a solution?
Comment #8
el1_1el commentedIve been struggling to update from 8.9.10 to 8.9.13 with and older composer.json using drupal/drupal. Ive tried various versions of twig and it seems this module became incompatible between twig versions 1.43.1 and 1.44.0. 1.44.1 was supposed to be the fix - https://github.com/twigphp/Twig/issues/3411 - however it did not work for me with this module.
If you need an immediate solution
composer require twig/twig:1.43.1seems to work, however it could bite you next time you do a composer update. It looks like maybe adding the sandbox extension (https://github.com/twigphp/Twig/issues/3411#issuecomment-714281764) or changing the twig (https://github.com/twigphp/Twig/issues/3411#issuecomment-713677851) might work but I dont see where the error occurs from this module, just can see that turning it off fixes the issue.Comment #9
olli commentedHere's a patch that seems to add back the missing checkSecurity method on drupal 9.1.4.
Comment #10
drupov commentedSuper! #9 Works for me! Thanks
Comment #11
el1_1el commented#9 working for me also. Thanks!
Comment #12
3li#9 has worked for me.
Comment #14
saschaeggiThanks y'all!