summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGabor Hojtsy2018-01-24 16:09:20 (GMT)
committerGabor Hojtsy2018-01-24 16:09:20 (GMT)
commit41116a5740346aed4bcefa6ea46e79a27c28290d (patch)
tree4a660d62b6d17f2adf6ace6188ac7cafa4f088a2
parent65388055254a41c340e4b53479ef5ac552627571 (diff)
Issue #2938947 by Wim Leers, plach: Always list a "Current revision" for each available content translation
-rw-r--r--core/modules/node/src/Controller/NodeController.php12
-rw-r--r--core/modules/node/tests/src/Functional/NodeRevisionsUiTest.php11
2 files changed, 19 insertions, 4 deletions
diff --git a/core/modules/node/src/Controller/NodeController.php b/core/modules/node/src/Controller/NodeController.php
index 4840147..e873f91 100644
--- a/core/modules/node/src/Controller/NodeController.php
+++ b/core/modules/node/src/Controller/NodeController.php
@@ -173,6 +173,7 @@ class NodeController extends ControllerBase implements ContainerInjectionInterfa
$rows = [];
$default_revision = $node->getRevisionId();
+ $current_revision_displayed = FALSE;
foreach ($this->getRevisionIds($node, $node_storage) as $vid) {
/** @var \Drupal\node\NodeInterface $revision */
@@ -187,11 +188,18 @@ class NodeController extends ControllerBase implements ContainerInjectionInterfa
// Use revision link to link to revisions that are not active.
$date = $this->dateFormatter->format($revision->revision_timestamp->value, 'short');
- if ($vid != $node->getRevisionId()) {
+
+ // We treat also the latest translation-affecting revision as current
+ // revision, if it was the default revision, as its values for the
+ // current language will be the same of the current default revision in
+ // this case.
+ $is_current_revision = $vid == $default_revision || (!$current_revision_displayed && $revision->wasDefaultRevision());
+ if (!$is_current_revision) {
$link = $this->l($date, new Url('entity.node.revision', ['node' => $node->id(), 'node_revision' => $vid]));
}
else {
$link = $node->link($date);
+ $current_revision_displayed = TRUE;
}
$row = [];
@@ -210,7 +218,7 @@ class NodeController extends ControllerBase implements ContainerInjectionInterfa
$this->renderer->addCacheableDependency($column['data'], $username);
$row[] = $column;
- if ($vid == $default_revision) {
+ if ($is_current_revision) {
$row[] = [
'data' => [
'#prefix' => '<em>',
diff --git a/core/modules/node/tests/src/Functional/NodeRevisionsUiTest.php b/core/modules/node/tests/src/Functional/NodeRevisionsUiTest.php
index a437e4a..3646ab3 100644
--- a/core/modules/node/tests/src/Functional/NodeRevisionsUiTest.php
+++ b/core/modules/node/tests/src/Functional/NodeRevisionsUiTest.php
@@ -160,10 +160,17 @@ class NodeRevisionsUiTest extends NodeTestBase {
$this->drupalGet('node/' . $node_id . '/revisions');
+ // Verify that the latest affected revision having been a default revision
+ // is displayed as the current one.
+ $this->assertNoLinkByHref('/node/' . $node_id . '/revisions/1/revert');
+ $elements = $this->xpath('//tr[contains(@class, "revision-current")]/td/a[1]');
+ // The site may be installed in a subdirectory, so check if the URL is
+ // contained in the retrieved one.
+ $this->assertContains('/node/1', current($elements)->getAttribute('href'));
+
// Verify that the default revision can be an older revision than the latest
// one.
- // Assert that the revisions with translations changes are shown: 1 and 4.
- $this->assertLinkByHref('/node/' . $node_id . '/revisions/1/revert');
+ // Assert that the revisions with translations changes are shown.
$this->assertLinkByHref('/node/' . $node_id . '/revisions/4/revert');
// Assert that the revisions without translations changes are filtered out: