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

Swap BC layer for yield-ready and reclaim perf loss #4216

Merged
merged 1 commit into from
Aug 19, 2024

Conversation

nicolas-grekas
Copy link
Contributor

Follows #3999

Fix #4146
Fix #4103

When use_yield is set to false (the default), this PR reverts the implementation of the render() method to use a wrapping output buffer instead of hooking between each steps of generators. In this mode, the behavior of the yield method is not "pure": it triggers a mix of yield and echo. But this is fine for render and display methods.

When use_yield is set to true, we skip that wrapping output buffer. This makes twig compatible with fibers (and this also makes compilation fail if a non-YieldReady extension is found.)

That makes the name of the option not ideal, but BC rulez FTW.

src/Template.php Outdated Show resolved Hide resolved
@fabpot
Copy link
Contributor

fabpot commented Aug 19, 2024

@nicolas-grekas Can you add a note in CHANGELOG?

@fabpot
Copy link
Contributor

fabpot commented Aug 19, 2024

@fabpot
Copy link
Contributor

fabpot commented Aug 19, 2024

Thank you @nicolas-grekas.

@fabpot fabpot merged commit 80c1574 into twigphp:3.x Aug 19, 2024
49 checks passed
@fabpot
Copy link
Contributor

fabpot commented Aug 19, 2024

Oops, forgot about the CHANGELOG. Fixed here: 3a307cd

@smnandre
Copy link
Contributor

Wow thank you @nicolas-grekas for this! 👏 🙇

fabpot added a commit that referenced this pull request Aug 27, 2024
This PR was merged into the 3.x branch.

Discussion
----------

Fix CoreExtension::captureOutput

Fix #4146

I forgot these lines in #4216

Commits
-------

7ba6866 Fix CoreExtension::captureOutput
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.

yield used when use_yield = false Performance regression since v3.9.0
4 participants