Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

call setEscaperRuntime() before calling Twig\Extension\EscaperExtension::addSafeClass(). #4082

Closed
tacman opened this issue May 11, 2024 · 1 comment · Fixed by #4083
Closed

Comments

@tacman
Copy link

tacman commented May 11, 2024

I just started getting this error, using Symfony ^7.0 for all the bundles.

 bin/console c:c -v

In EscaperExtension.php line 177:
                                                                                                     
  [LogicException]                                                                                   
  You must call setEscaperRuntime() before calling Twig\Extension\EscaperExtension::addSafeClass().  
                                                                                                     
Exception trace:
  at /home/tac/g/sites/packages/vendor/twig/twig/src/Extension/EscaperExtension.php:177
 Twig\Extension\EscaperExtension->addSafeClass() at /home/tac/g/sites/packages/vendor/symfony/ux-twig-component/src/Twig/TwigEnvironmentConfigurator.php:35
 Symfony\UX\TwigComponent\Twig\TwigEnvironmentConfigurator->configure() at /home/tac/g/sites/packages/var/cache/test/ContainerBaHlBOQ/App_KernelTestDebugContainer.php:5596
 ContainerBaHlBOQ\App_KernelTestDebugContainer::getTwigService() at /home/tac/g/sites/packages/var/cache/test/ContainerBaHlBOQ/App_KernelTestDebugContainer.php:3737
 ContainerBaHlBOQ\App_KernelTestDebugContainer::getDataCollector_TwigService() at /home/tac/g/sites/packages/var/cache/test/ContainerBaHlBOQ/App_KernelTestDebugContainer.php:762
 ContainerBaHlBOQ\App_KernelTestDebugContainer::get_Container_Private_ProfilerService() at /home/tac/g/sites/packages/var/cache/test/ContainerBaHlBOQ/getConsoleProfilerListenerService.php:23
 ContainerBaHlBOQ\getConsoleProfilerListenerService::do() at /home/tac/g/sites/packages/var/cache/test/ContainerBaHlBOQ/App_KernelTestDebugContainer.php:728
 ContainerBaHlBOQ\App_KernelTestDebugContainer->load() at /home/tac/g/sites/packages/var/cache/test/ContainerBaHlBOQ/App_KernelTestDebugContainer.php:999
 ContainerBaHlBOQ\App_KernelTestDebugContainer::ContainerBaHlBOQ\{closure}() at /home/tac/g/sites/packages/vendor/symfony/event-dispatcher/EventDispatcher.php:221
 Symfony\Component\EventDispatcher\EventDispatcher->sortListeners() at /home/tac/g/sites/packages/vendor/symfony/event-dispatcher/EventDispatcher.php:70
 Symfony\Component\EventDispatcher\EventDispatcher->getListeners() at /home/tac/g/sites/packages/vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php:257
 Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher->preProcess() at /home/tac/g/sites/packages/vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php:121
 Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher->dispatch() at /home/tac/g/sites/packages/vendor/symfony/console/Application.php:1046
 Symfony\Component\Console\Application->doRunCommand() at /home/tac/g/sites/packages/vendor/symfony/framework-bundle/Console/Application.php:125
 Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand() at /home/tac/g/sites/packages/vendor/symfony/console/Application.php:318
 Symfony\Component\Console\Application->doRun() at /home/tac/g/sites/packages/vendor/symfony/framework-bundle/Console/Application.php:79
 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /home/tac/g/sites/packages/vendor/symfony/console/Application.php:169
 Symfony\Component\Console\Application->run() at /home/tac/g/sites/packages/vendor/symfony/runtime/Runner/Symfony/ConsoleApplicationRunner.php:49
 Symfony\Component\Runtime\Runner\Symfony\ConsoleApplicationRunner->run() at /home/tac/g/sites/packages/vendor/autoload_runtime.php:29
 require_once() at /home/tac/g/sites/packages/bin/console:11

tacman referenced this issue in symfony/ux-twig-component May 11, 2024
@tacman
Copy link
Author

tacman commented May 11, 2024

locking twig/twig to 3.9 temporarily fixes the problem.

This is happening consistently in my applications which use twig and ux-twig-component.


  - Downgrading twig/intl-extra (v3.10.0 => v3.9.2)
  - Downgrading twig/twig (v3.10.0 => v3.9.3)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 0 installs, 2 updates, 0 removals
  - Downgrading twig/twig (v3.10.0 => v3.9.3): Extracting archive
  - Downgrading twig/intl-extra (v3.10.0 => v3.9.2): Extracting archive
Package php-http/message-factory is abandoned, you should avoid using it. Use psr/http-factory instead.
Generating autoload files
139 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
Endroid Installer detected project type "symfony"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

1 participant