From 6665f8bf194346ea7d817893e9412cdb303baba0 Mon Sep 17 00:00:00 2001 From: John Koster Date: Sat, 14 Feb 2026 16:22:29 -0600 Subject: [PATCH 1/3] Fixes an issue with PHP tag and assugnments --- .../Language/Runtime/NodeProcessor.php | 5 ++- tests/Antlers/Runtime/ParserIsolationTest.php | 44 +++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/src/View/Antlers/Language/Runtime/NodeProcessor.php b/src/View/Antlers/Language/Runtime/NodeProcessor.php index b134341c7fb..7ddcc7fe894 100644 --- a/src/View/Antlers/Language/Runtime/NodeProcessor.php +++ b/src/View/Antlers/Language/Runtime/NodeProcessor.php @@ -2557,7 +2557,10 @@ private function evaluatePhpBuffer(string $___phpBuffer, bool $___processAssignm $___antlersVarAfter = get_defined_vars(); foreach ($___antlersVarAfter as $___varKey => $___varValue) { - if (str_starts_with($___varKey, '___')) { + if ( + str_starts_with($___varKey, '___') || + isset($___antlersVarBefore[$___varKey]) && $___antlersVarBefore[$___varKey] == $___varValue + ) { continue; } diff --git a/tests/Antlers/Runtime/ParserIsolationTest.php b/tests/Antlers/Runtime/ParserIsolationTest.php index 90b5c162120..532916f1ba7 100644 --- a/tests/Antlers/Runtime/ParserIsolationTest.php +++ b/tests/Antlers/Runtime/ParserIsolationTest.php @@ -3,6 +3,7 @@ namespace Tests\Antlers\Runtime; use Facades\Tests\Factories\EntryFactory; +use Illuminate\Support\Str; use Statamic\Facades\Collection; use Statamic\Facades\Nav; use Statamic\Facades\Taxonomy; @@ -274,4 +275,47 @@ public function test_escaped_braces_in_concurrent_requests() $this->assertSame($expectedOne, $contentOne); $this->assertSame($expectedTwo, $contentTwo); } + + public function test_php_nodes_do_overwrite_parent_scope_needlessly() + { + $this->createBlueprintsAndData(); + $this->withFakeViews(); + + $layout = <<<'EOT' +{{ template_content }} +Layout: {{ title }} +EOT; + + $template = <<<'EOT' +{{? + $loop_data = [ + [ + 'title' => 'A different title', + ], + ]; +?}} + +Before: {{ title }} +{{ collection:news }} + {{ collection:news }} + {{ loop_data }} + {{? /* */ ?}} + {{ /loop_data }} + {{ /collection:news }} +{{ /collection:news }} +After: {{ title }} +EOT; + + $this->viewShouldReturnRaw('layout', $layout); + $this->viewShouldReturnRaw('default', $template); + + $result = $this->get('bravo/news-2') + ->assertOk() + ->content(); + + $this->assertSame( + 'Before: News 2 After: News 2 Layout: News 2', + Str::squish($result) + ); + } } From 4393203cfd0ed5c8aed253f08ff885e1b6beaed8 Mon Sep 17 00:00:00 2001 From: Jason Varga Date: Mon, 16 Feb 2026 11:54:04 -0500 Subject: [PATCH 2/3] dont --- tests/Antlers/Runtime/ParserIsolationTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Antlers/Runtime/ParserIsolationTest.php b/tests/Antlers/Runtime/ParserIsolationTest.php index 532916f1ba7..3025b456c4f 100644 --- a/tests/Antlers/Runtime/ParserIsolationTest.php +++ b/tests/Antlers/Runtime/ParserIsolationTest.php @@ -276,7 +276,7 @@ public function test_escaped_braces_in_concurrent_requests() $this->assertSame($expectedTwo, $contentTwo); } - public function test_php_nodes_do_overwrite_parent_scope_needlessly() + public function test_php_nodes_dont_overwrite_parent_scope_needlessly() { $this->createBlueprintsAndData(); $this->withFakeViews(); From 12509ef860c12b779b7f074dbb2b2a2225b9f979 Mon Sep 17 00:00:00 2001 From: Jason Varga Date: Mon, 16 Feb 2026 13:59:15 -0500 Subject: [PATCH 3/3] use strict comparison and wrap with parens --- src/View/Antlers/Language/Runtime/NodeProcessor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/View/Antlers/Language/Runtime/NodeProcessor.php b/src/View/Antlers/Language/Runtime/NodeProcessor.php index 7ddcc7fe894..6e0e677aff7 100644 --- a/src/View/Antlers/Language/Runtime/NodeProcessor.php +++ b/src/View/Antlers/Language/Runtime/NodeProcessor.php @@ -2559,7 +2559,7 @@ private function evaluatePhpBuffer(string $___phpBuffer, bool $___processAssignm foreach ($___antlersVarAfter as $___varKey => $___varValue) { if ( str_starts_with($___varKey, '___') || - isset($___antlersVarBefore[$___varKey]) && $___antlersVarBefore[$___varKey] == $___varValue + (isset($___antlersVarBefore[$___varKey]) && $___antlersVarBefore[$___varKey] === $___varValue) ) { continue; }