Skip to content

Lazy load EscaperRuntime in EscaperExtension#4795

Merged
fabpot merged 1 commit into
twigphp:3.xfrom
GromNaN:lazy-escaper-runtime
May 17, 2026
Merged

Lazy load EscaperRuntime in EscaperExtension#4795
fabpot merged 1 commit into
twigphp:3.xfrom
GromNaN:lazy-escaper-runtime

Conversation

@GromNaN

@GromNaN GromNaN commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

This allows overriding EscaperRuntime via a custom runtime loader.

Previously, EscaperExtension::setEnvironment() was calling $environment->getRuntime(EscaperRuntime::class) eagerly. Since this method is called from Environment::__construct(), the runtime was resolved before any custom runtime loader could be injected, making it impossible to override EscaperRuntime.

@GromNaN GromNaN force-pushed the lazy-escaper-runtime branch from 69af2b7 to 7931fdd Compare April 30, 2026 11:36
Previously, setEnvironment() called getRuntime(EscaperRuntime::class) eagerly,
which prevented overriding EscaperRuntime via a custom runtime loader since
Environment::__construct() calls setEnvironment() before any loader can be injected.
@fabpot

fabpot commented May 17, 2026

Copy link
Copy Markdown
Contributor

Thank you @GromNaN.

@fabpot fabpot merged commit fd0760d into twigphp:3.x May 17, 2026
39 of 41 checks passed
@GromNaN GromNaN deleted the lazy-escaper-runtime branch May 17, 2026 08:14
nicolas-grekas pushed a commit to symfony/symfony that referenced this pull request May 19, 2026
nicolas-grekas added a commit to symfony/symfony that referenced this pull request May 19, 2026
…vice definition (GromNaN)

This PR was merged into the 8.1 branch.

Discussion
----------

[TwigBridge] Require Twig to 3.25 for `EscaperRuntime` service definition

| Q             | A
| ------------- | ---
| Branch?       | 8.1
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Issues        | -
| License       | MIT

The feature introduced by #63929 is broken with older versions of Twig. The patch twigphp/Twig#4795 was released in [v3.25.0](https://github.com/twigphp/Twig/releases/tag/v3.25.0)

Commits
-------

f2bb4df [TwigBridge] Update required twig version for EscaperRuntime service definition
symfony-splitter pushed a commit to symfony/twig-bridge that referenced this pull request May 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants