From 31d3a93defdf6c9bfc503eb6930c8d2705475974 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joachim=20R=C3=BCtter?= Date: Wed, 15 Jul 2026 16:33:21 +0200 Subject: [PATCH] Fix null scope variables leaking as assignments from Antlers PHP nodes Co-Authored-By: Claude Fable 5 --- src/View/Antlers/Language/Runtime/NodeProcessor.php | 2 +- tests/Antlers/Runtime/PartialsTest.php | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/View/Antlers/Language/Runtime/NodeProcessor.php b/src/View/Antlers/Language/Runtime/NodeProcessor.php index 2d4a117668f..1d7bf42b81a 100644 --- a/src/View/Antlers/Language/Runtime/NodeProcessor.php +++ b/src/View/Antlers/Language/Runtime/NodeProcessor.php @@ -2589,7 +2589,7 @@ private function evaluatePhpBuffer(string $___phpBuffer, bool $___processAssignm foreach ($___antlersVarAfter as $___varKey => $___varValue) { if ( str_starts_with($___varKey, '___') || - (isset($___antlersVarBefore[$___varKey]) && $___antlersVarBefore[$___varKey] === $___varValue) + (array_key_exists($___varKey, $___antlersVarBefore) && $___antlersVarBefore[$___varKey] === $___varValue) ) { continue; } diff --git a/tests/Antlers/Runtime/PartialsTest.php b/tests/Antlers/Runtime/PartialsTest.php index 99b5de565a7..223a3f2c555 100644 --- a/tests/Antlers/Runtime/PartialsTest.php +++ b/tests/Antlers/Runtime/PartialsTest.php @@ -82,4 +82,17 @@ public function test_double_colons_may_be_used_in_tag_method_part() $this->renderString($template, [], true); } + + public function test_assignments_in_earlier_partials_do_not_blank_a_later_partials_slot() + { + $template = <<<'EOT' +{{? $foo = 'bar' ?}}{{ partial:filter /}}{{ partial:card }}KEEPME{{ /partial:card }} +EOT; + + $this->withFakeViews(); + $this->viewShouldReturnRaw('filter', "{{? \$values = 'v' ?}}FILTER"); + $this->viewShouldReturnRaw('card', "{{ trans key='hi' }}{{ slot }}"); + + $this->assertSame('FILTERhiKEEPME', $this->renderString($template, [], true)); + } }