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

[BUG] Twig 3.10 breaks Timber #2993

Closed
rmens opened this issue May 11, 2024 · 4 comments · Fixed by #2997
Closed

[BUG] Twig 3.10 breaks Timber #2993

rmens opened this issue May 11, 2024 · 4 comments · Fixed by #2997

Comments

@rmens
Copy link
Contributor

rmens commented May 11, 2024

Expected Behavior

Timber to work with Twig 3.10 that is allowed to be installed according to the included composer.json.

Actual behavior

Fatal error: Uncaught Exception: You must call "setEnvironment()" before calling "Twig\Extension\EscaperExtension::setEscaper()".
in /home/zwupdate/domains/redacted.nl/public_html/wp-content/themes/streekomroep-prod/vendor/twig/twig/src/Extension/EscaperExtension.php on line 127

Call stack:

Twig\Extension\EscaperExtension::setEscaper()
wp-content/themes/streekomroep-prod/vendor/timber/timber/src/Twig.php:558
Timber\Twig::add_timber_escapers()
wp-includes/class-wp-hook.php:324
WP_Hook::apply_filters()
wp-includes/plugin.php:205
apply_filters()
wp-content/themes/streekomroep-prod/vendor/timber/timber/src/Loader.php:518
Timber\Loader::get_twig()
wp-content/themes/streekomroep-prod/vendor/timber/timber/src/Loader.php:120
Timber\Loader::render()
wp-content/themes/streekomroep-prod/vendor/timber/timber/src/Timber.php:1444
Timber\Timber::compile()
wp-content/themes/streekomroep-prod/vendor/timber/timber/src/Timber.php:1579
Timber\Timber::render()
wp-content/themes/streekomroep-prod/single.php:222

Steps to reproduce behavior

  1. Install Twig with the composer.json that ships with the project.

Notes

Added "twig/twig": "3.9.3", to my composer.json to fix it for now.

What version of Timber are you using?

Timber 2.1.0

What version of WordPress are you using?

WordPress 6.5

What version of PHP are you using?

PHP 8.2

How did you install Timber?

Installed or updated Timber through Composer

@cronin4392
Copy link

Ran into this as well and downgrading twig worked as a work around for me.

@gchtr
Copy link
Member

gchtr commented May 13, 2024

It looks like this was already fixed in Twig version 3.10.1 (see twigphp/Twig#4083 and the Changelog for 3.10.1).

Can someone confirm this fixes the Fatal Error?

There might still be a deprecation that we might handle. Maybe we need to register Timber’s escapers differently, so they don’t break in the future. I didn’t have the time yet to investigate further, though.

@pgnd
Copy link

pgnd commented May 13, 2024

confirmed, here

with

composer show twig/twig | grep version
	versions : * v3.10.1

all good

reported in # flyntwp/flynt#554

@rmens
Copy link
Contributor Author

rmens commented May 13, 2024

Can also confirm that Twig 3.10.1 makes it work again. Great to see quick patching of the deprecations too! 👏

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

Successfully merging a pull request may close this issue.

5 participants