diff --git a/src/View/Antlers/Language/Runtime/GlobalRuntimeState.php b/src/View/Antlers/Language/Runtime/GlobalRuntimeState.php index b60ce9abb10..e2d9ab9b038 100644 --- a/src/View/Antlers/Language/Runtime/GlobalRuntimeState.php +++ b/src/View/Antlers/Language/Runtime/GlobalRuntimeState.php @@ -290,6 +290,7 @@ public static function resetGlobalState() self::$tracedRuntimeAssignments = []; self::$traceTagAssignments = false; self::$environmentId = StringUtilities::uuidv4(); + self::$interpolatedVariables = []; self::$yieldCount = 0; self::$yieldStacks = []; self::$abandonedNodes = []; diff --git a/tests/View/StateTest.php b/tests/View/StateTest.php index ca626c5731f..2d725b06626 100644 --- a/tests/View/StateTest.php +++ b/tests/View/StateTest.php @@ -2,6 +2,7 @@ namespace Tests\View; +use Statamic\View\Antlers\Language\Runtime\GlobalRuntimeState; use Statamic\View\Antlers\Language\Utilities\StringUtilities; use Tests\FakesContent; use Tests\FakesViews; @@ -50,6 +51,27 @@ public function test_tag_state_is_cleared_between_responses() $this->assertSame($expected, $resultThree); } + public function test_interpolated_variables_are_cleared_between_responses() + { + $this->withFakeViews(); + $this->viewShouldReturnRaw('layout', '{{ template_content }}'); + $this->viewShouldReturnRaw('default', '{{ link to="/pages/{slug}" }} {{ num | add:{num} }}'); + + $this->createPage('home', [ + 'with' => [ + 'title' => 'Home Page', + 'num' => 3, + 'template' => 'default', + ], + ]); + + $this->assertSame('/pages/home 6', $this->getResponseContent('/home')); + $this->assertSame([], GlobalRuntimeState::$interpolatedVariables); + + $this->assertSame('/pages/home 6', $this->getResponseContent('/home')); + $this->assertSame([], GlobalRuntimeState::$interpolatedVariables); + } + protected function getResponseContent($uri) { $response = $this->get($uri)->assertStatus(200);