diff --git a/core/modules/node/src/Controller/NodeController.php b/core/modules/node/src/Controller/NodeController.php index 8fd04b6..9bc7453 100644 --- a/core/modules/node/src/Controller/NodeController.php +++ b/core/modules/node/src/Controller/NodeController.php @@ -173,7 +173,7 @@ public function revisionOverview(NodeInterface $node) { $vids = $node_storage->revisionIds($node); - $latest_revision = TRUE; + $default_revision = $node->getRevisionId(); foreach (array_reverse($vids) as $vid) { /** @var \Drupal\node\NodeInterface $revision */ @@ -211,7 +211,7 @@ public function revisionOverview(NodeInterface $node) { $this->renderer->addCacheableDependency($column['data'], $username); $row[] = $column; - if ($latest_revision) { + if ($vid == $default_revision) { $row[] = [ 'data' => [ '#prefix' => '', @@ -219,16 +219,13 @@ public function revisionOverview(NodeInterface $node) { '#suffix' => '', ], ]; - foreach ($row as &$current) { - $current['class'] = ['revision-current']; - } - $latest_revision = FALSE; + $class = ['revision-current', $vid]; } else { $links = []; if ($revert_permission) { $links['revert'] = [ - 'title' => $this->t('Revert'), + 'title' => $vid < $node->getRevisionId() ? $this->t('Revert') : $this->t('Set as current revision'), 'url' => $has_translations ? Url::fromRoute('node.revision_revert_translation_confirm', ['node' => $node->id(), 'node_revision' => $vid, 'langcode' => $langcode]) : Url::fromRoute('node.revision_revert_confirm', ['node' => $node->id(), 'node_revision' => $vid]), @@ -248,9 +245,13 @@ public function revisionOverview(NodeInterface $node) { '#links' => $links, ], ]; + $class = [$vid]; } - $rows[] = $row; + $rows[] = [ + 'data' => $row, + 'class' => $class, + ]; } } diff --git a/core/modules/node/src/Tests/NodeRevisionsUiTest.php b/core/modules/node/src/Tests/NodeRevisionsUiTest.php index 278809a..47a396a 100644 --- a/core/modules/node/src/Tests/NodeRevisionsUiTest.php +++ b/core/modules/node/src/Tests/NodeRevisionsUiTest.php @@ -121,4 +121,40 @@ public function testNodeRevisionDoubleEscapeFix() { $this->assertRaw($nodes[1]->link($date) . ' by ' . $editor . '

' . $revision_log . '

'); } + /** + * Checks the Revisions tab. + */ + public function testNodeRevisionsTab() { + $this->drupalLogin($this->editor); + + // Create the node. + $node = $this->drupalCreateNode(); + + // Create revision with a random title and body and update variables. + $node->title = $this->randomMachineName(); + $node->body = [ + 'value' => $this->randomMachineName(32), + 'format' => filter_default_format(), + ]; + $node->setNewRevision(TRUE); + $node->save(); + $node->setNewRevision(TRUE); + $node->save(); + $node->isDefaultRevision(FALSE); + $node->setNewRevision(TRUE); + $node->save(); + $node->isDefaultRevision(FALSE); + $node->setNewRevision(TRUE); + $node->save(); + + $this->drupalGet('node/' . $node->id() . '/revisions'); + + $this->assertRaw('Set as current revision'); + $this->assertRaw('Set as current revision'); + $this->assertRaw(''); + $this->assertRaw('Revert'); + $this->assertRaw('Revert'); + + } + }