From 36145a511bc8a37e93c2344adddc7ed72c206fb8 Mon Sep 17 00:00:00 2001 From: bnjmnm <benm@umich.edu> Date: Wed, 1 Mar 2023 08:34:25 -0500 Subject: [PATCH] Issue #3342891 by lauriii, smustgrave, andy-blum, catch: 'node' variable in page.html.twig is not available on preview node page --- core/includes/theme.inc | 2 +- .../tests/src/Functional/DemoUmamiProfileTest.php | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/core/includes/theme.inc b/core/includes/theme.inc index f2bce97ff336..7ece51e4bf5a 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -1375,7 +1375,7 @@ function template_preprocess_page(&$variables) { $variables['db_is_active'] = FALSE; } - if ($node = \Drupal::routeMatch()->getParameter('node')) { + if (($node = \Drupal::routeMatch()->getParameter('node')) || ($node = \Drupal::routeMatch()->getParameter('node_preview'))) { $variables['node'] = $node; } } diff --git a/core/profiles/demo_umami/tests/src/Functional/DemoUmamiProfileTest.php b/core/profiles/demo_umami/tests/src/Functional/DemoUmamiProfileTest.php index 89f6a6a20ead..39b9b2bddf7d 100644 --- a/core/profiles/demo_umami/tests/src/Functional/DemoUmamiProfileTest.php +++ b/core/profiles/demo_umami/tests/src/Functional/DemoUmamiProfileTest.php @@ -128,6 +128,12 @@ public function testEditNodesByAdmin() { $node = reset($nodes); $this->drupalGet($node->toUrl('edit-form')); $webassert->statusCodeEquals('200'); + + $this->submitForm([], 'Preview'); + $webassert->statusCodeEquals('200'); + $this->assertSession()->elementsCount('css', 'h1', 1); + $this->clickLink('Back to content editing'); + $this->submitForm([], "Save"); $webassert->pageTextContains('Recipe Deep mediterranean quiche has been updated.'); } -- GitLab