Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/View/Antlers/Language/Runtime/NodeProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
44 changes: 44 additions & 0 deletions tests/Antlers/Runtime/ParserIsolationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
);
}
}
Loading