I encountered an issue that could be related:
I updated from Drupal 9.4.* to 9.5.9
I get "Unexpected error" when editing any content
[Wed May 10 09:50:14.869552 2023] [fcgid:warn] [pid 11408] [client *.*.*.*:46876] mod_fcgid: stderr: Uncaught PHP Exception Twig\\Error\\LoaderError: "Template "__TwigTemplate_047b58c6305e4dae7186194282b494cb6638f318afe38d7f4070d4a568809716" is not defined." at /home/httpd/vhosts/***.***/***.***/vendor/twig/twig/src/Loader/ChainLoader.php line 98, referer: https://****/admin/content
This happened with Seven as an admin theme
Tried to switch to Claro, still same error.The template file does not exist.
What could cause this ?
- 🇫🇷France Toki Caen, Normandy
I had the same error message last week and it was related to a contrib module "Permissions by Term".
See this issue here : https://www.drupal.org/project/drupal/issues/3358534 🐛 Twig template not defined, LoaderError Closed: duplicate - 🇺🇦Ukraine venoel
Local environment
Drupal v.9.5.9
> composer show twig/twig Twig v2.15.5
The same error
Twig\Error\LoaderError: Template "@claro/../images/src/hamburger-menu.svg" is not defined in "core/themes/claro/templates/navigation/menu-local-task.html.twig" at line 30. in Twig\Loader\ChainLoader->getCacheKey() (line 98 of /home/user/www/project/vendor/twig/twig/src/Loader/ChainLoader.php).
Downgrade to Twig v2.15.4 does not resolve problem.
Production environment
Drupal 9.5.2
> composer show twig/twig Twig v2.15.4
There is no such error.
May be we need some magic drums?
- 🇺🇸United States crutch
#52 has fixes this for us, currently on twig 2.15.4. Reference: https://www.drupal.org/project/drupal/issues/3358534 🐛 Twig template not defined, LoaderError Closed: duplicate and https://www.drupal.org/project/permissions_by_term/issues/3354478#commen... 🐛 Regression updating to 3.1.22 for Drupal 9.x using loadTemplate from twig Fixed
Production
Production is a cloud server where we can pick to use PHP 8.1. However, composer complains about the server using PHP 7.x. This is where we have experienced the issue after updating core.Local
There is no issue here because it is a pure PHP 8.1 environment (assumption). - 🇨🇦Canada joseph.olstad
@snehal mhamane, at this point this bug was fixed long ago upstream in twig/twig, you should no longer be locking twig/twig to such an old version.
I suggest upgrading your dependencies. Remove the twig/twig entry in your composer.json
Unlock your Drupal core from version X to 9.4.7+ 9.5+ or 10+ f
composer up -W
If you need assistance on upgrading to Drupal 10.0.10 please install the upgrade_status module , it has a report that helps you upgrade as much as possible while still using Drupal 9. Once you're in Drupal 10 you can uninstall upgrade_status until Drupal 11 is ready.
composer require drupal/upgrade_status
drush cr; drush en upgrade_status -y;
Once installed, there will be a scanning tool available for your custom modules.
drush us-a modulename;
scan your custom modules using this tool and follow the instructions in the report, rescan after you make the recommended change until the scan report comes out clean.
When in doubt, refer to this guide on upgrading from Drupal 9 to Drupal 10 →