Unverified Commit 44f56c2c authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3227637 by larowlan, acbramley, daffie, amber himes matz, yogeshmpawar,...

Issue #3227637 by larowlan, acbramley, daffie, amber himes matz, yogeshmpawar, fubarhouse, chetanbharambe, jibran, catch, kristen pol, alexpott: NodeController::revisionOverview is uncacheable
parent 733dc5fc
Loading
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -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;
@@ -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) {
+16 −0
Original line number Diff line number Diff line
@@ -215,4 +215,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');
  }

}