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

Fix blocks not available under some circumstancies #4081

Merged
merged 2 commits into from May 11, 2024

Conversation

fabpot
Copy link
Contributor

@fabpot fabpot commented May 11, 2024

Fix #4079

@@ -24,7 +24,7 @@ class CaptureNode extends Node
{
public function __construct(Node $body, int $lineno, ?string $tag = null)
{
parent::__construct(['body' => $body], ['raw' => false, 'with_blocks' => false], $lineno, $tag);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$blocks should always be passed to the anonymous function as used by many Twig features.

@@ -40,7 +40,7 @@ public function compile(Compiler $compiler): void
->addDebugInfo($this)
->raw('$this->env->getRuntime(\'Twig\Extra\Cache\CacheRuntime\')->getCache()->get(')
->subcompile($this->getNode('key'))
->raw(", function (\Symfony\Contracts\Cache\ItemInterface \$item) use (\$context, \$macros) {\n")
->raw(", function (\Symfony\Contracts\Cache\ItemInterface \$item) use (\$context, \$macros, \$blocks) {\n")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This bug is independent of the new CaptureNode feature, but it's now more obvious.

@fabpot fabpot merged commit 6da7a95 into twigphp:3.x May 11, 2024
66 of 77 checks passed
@fabpot fabpot deleted the blocks-passing-fix branch May 11, 2024 07:03
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.

Warning in compiled Twig template : "Warning: Undefined variable $blocks"
1 participant