From a56fa00112c9b80b71bec1131314d679be8b1af0 Mon Sep 17 00:00:00 2001
From: Nathaniel Catchpole <catch@35733.no-reply.drupal.org>
Date: Wed, 11 Nov 2015 12:08:56 +0000
Subject: [PATCH] Issue #2495297 by jhedstrom, snehi: [regression] Display
 revision_uid editor name if different from uid on node revision overview page

---
 .../node/src/Controller/NodeController.php    |  2 +-
 .../node/src/Tests/NodeRevisionsTest.php      | 27 +++++++++++++++++++
 2 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/core/modules/node/src/Controller/NodeController.php b/core/modules/node/src/Controller/NodeController.php
index a43bb53a8208..3c534f2ea6b7 100644
--- a/core/modules/node/src/Controller/NodeController.php
+++ b/core/modules/node/src/Controller/NodeController.php
@@ -187,7 +187,7 @@ public function revisionOverview(NodeInterface $node) {
       if ($revision->hasTranslation($langcode) && $revision->getTranslation($langcode)->isRevisionTranslationAffected()) {
         $username = [
           '#theme' => 'username',
-          '#account' => $revision->uid->entity,
+          '#account' => $revision->getRevisionAuthor(),
         ];
 
         // Use revision link to link to revisions that are not active.
diff --git a/core/modules/node/src/Tests/NodeRevisionsTest.php b/core/modules/node/src/Tests/NodeRevisionsTest.php
index 2e311457641c..45fa06d5837f 100644
--- a/core/modules/node/src/Tests/NodeRevisionsTest.php
+++ b/core/modules/node/src/Tests/NodeRevisionsTest.php
@@ -21,7 +21,19 @@
  * @group node
  */
 class NodeRevisionsTest extends NodeTestBase {
+
+  /**
+   * An array of node revisions.
+   *
+   * @var \Drupal\node\NodeInterface[]
+   */
   protected $nodes;
+
+  /**
+   * Revision log messages.
+   *
+   * @var array
+   */
   protected $revisionLogs;
 
   /**
@@ -93,6 +105,16 @@ protected function setUp() {
       );
       $node->untranslatable_string_field->value = $this->randomString();
       $node->setNewRevision();
+
+      // Edit the 2nd revision with a different user.
+      if ($i == 1) {
+        $editor = $this->drupalCreateUser();
+        $node->setRevisionAuthorId($editor->id());
+      }
+      else {
+        $node->setRevisionAuthorId($web_user->id());
+      }
+
       $node->save();
 
       $node = Node::load($node->id()); // Make sure we get revision information.
@@ -123,6 +145,11 @@ function testRevisions() {
     foreach ($logs as $revision_log) {
       $this->assertText($revision_log, 'Revision log message found.');
     }
+    // Original author, and editor names should appear on revisions overview.
+    $web_user = $nodes[0]->revision_uid->entity;
+    $this->assertText(t('by @name', ['@name' => $web_user->getAccountName()]));
+    $editor = $nodes[2]->revision_uid->entity;
+    $this->assertText(t('by @name', ['@name' => $editor->getAccountName()]));
 
     // Confirm that this is the default revision.
     $this->assertTrue($node->isDefaultRevision(), 'Third node revision is the default one.');
-- 
GitLab