Loading core/modules/node/src/Controller/NodeController.php +2 −1 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ namespace Drupal\node\Controller; use Drupal\Component\Utility\Xss; use Drupal\Core\Cache\CacheableMetadata; use Drupal\Core\Controller\ControllerBase; use Drupal\Core\Datetime\DateFormatterInterface; use Drupal\Core\DependencyInjection\ContainerInjectionInterface; Loading Loading @@ -199,7 +200,7 @@ public function revisionOverview(NodeInterface $node) { ], ]; // @todo Simplify once https://www.drupal.org/node/2334319 lands. $this->renderer->addCacheableDependency($column['data'], $username); $this->renderer->addCacheableDependency($column['data'], CacheableMetadata::createFromRenderArray($username)); $row[] = $column; if ($is_current_revision) { Loading core/modules/node/tests/src/Functional/NodeRevisionsUiTest.php +16 −0 Original line number Diff line number Diff line Loading @@ -217,4 +217,20 @@ public function testNodeDuplicateRevisionsTab(): void { $this->assertSession()->elementsCount('xpath', $xpath, 1); } /** * Tests the node revisions page is cacheable by dynamic page cache. */ public function testNodeRevisionsCacheability(): void { $this->drupalLogin($this->editor); $node = $this->drupalCreateNode(); // Admin paths are always uncacheable by dynamic page cache, swap node // to non admin theme to test cacheability. $this->config('node.settings')->set('use_admin_theme', FALSE)->save(); \Drupal::service('router.builder')->rebuild(); $this->drupalGet($node->toUrl('version-history')); $this->assertSession()->responseHeaderEquals('X-Drupal-Dynamic-Cache', 'MISS'); $this->drupalGet($node->toUrl('version-history')); $this->assertSession()->responseHeaderEquals('X-Drupal-Dynamic-Cache', 'HIT'); } } Loading
core/modules/node/src/Controller/NodeController.php +2 −1 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ namespace Drupal\node\Controller; use Drupal\Component\Utility\Xss; use Drupal\Core\Cache\CacheableMetadata; use Drupal\Core\Controller\ControllerBase; use Drupal\Core\Datetime\DateFormatterInterface; use Drupal\Core\DependencyInjection\ContainerInjectionInterface; Loading Loading @@ -199,7 +200,7 @@ public function revisionOverview(NodeInterface $node) { ], ]; // @todo Simplify once https://www.drupal.org/node/2334319 lands. $this->renderer->addCacheableDependency($column['data'], $username); $this->renderer->addCacheableDependency($column['data'], CacheableMetadata::createFromRenderArray($username)); $row[] = $column; if ($is_current_revision) { Loading
core/modules/node/tests/src/Functional/NodeRevisionsUiTest.php +16 −0 Original line number Diff line number Diff line Loading @@ -217,4 +217,20 @@ public function testNodeDuplicateRevisionsTab(): void { $this->assertSession()->elementsCount('xpath', $xpath, 1); } /** * Tests the node revisions page is cacheable by dynamic page cache. */ public function testNodeRevisionsCacheability(): void { $this->drupalLogin($this->editor); $node = $this->drupalCreateNode(); // Admin paths are always uncacheable by dynamic page cache, swap node // to non admin theme to test cacheability. $this->config('node.settings')->set('use_admin_theme', FALSE)->save(); \Drupal::service('router.builder')->rebuild(); $this->drupalGet($node->toUrl('version-history')); $this->assertSession()->responseHeaderEquals('X-Drupal-Dynamic-Cache', 'MISS'); $this->drupalGet($node->toUrl('version-history')); $this->assertSession()->responseHeaderEquals('X-Drupal-Dynamic-Cache', 'HIT'); } }