diff --git a/core/modules/comment/src/Entity/Comment.php b/core/modules/comment/src/Entity/Comment.php
index e2ab3d8..d057203 100644
--- a/core/modules/comment/src/Entity/Comment.php
+++ b/core/modules/comment/src/Entity/Comment.php
@@ -138,15 +138,18 @@ public function preSave(EntityStorageInterface $storage) {
         } while (!\Drupal::lock()->acquire($lock_name));
         $this->threadLock = $lock_name;
       }
-      // We test the value with '===' because we need to modify anonymous
-      // users as well.
-      if ($this->getOwnerId() === \Drupal::currentUser()->id() && \Drupal::currentUser()->isAuthenticated()) {
-        $this->setAuthorName(\Drupal::currentUser()->getUsername());
-      }
       // Add the values which aren't passed into the function.
       $this->setThread($thread);
       $this->setHostname(\Drupal::request()->getClientIP());
     }
+    // The entity fields for name and mail have no meaning if the user is not
+    // Anonymous. Set them to NULL to make it clearer that they are not used.
+    // For anonymous users see \Drupal\comment\CommentForm::form() for mail, and
+    // \Drupal\comment\CommentForm::buildEntity() for name setting.
+    if (!$this->getOwner()->isAnonymous()) {
+      $this->set('name', NULL);
+      $this->set('mail', NULL);
+    }
   }
 
   /**
@@ -267,14 +270,14 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
 
     $fields['name'] = BaseFieldDefinition::create('string')
       ->setLabel(t('Name'))
-      ->setDescription(t("The comment author's name."))
+      ->setDescription(t("The comment author's name for anonymous users."))
       ->setTranslatable(TRUE)
       ->setSetting('max_length', 60)
       ->setDefaultValue('');
 
     $fields['mail'] = BaseFieldDefinition::create('email')
       ->setLabel(t('Email'))
-      ->setDescription(t("The comment author's email address."))
+      ->setDescription(t("The comment author's email address for anonymous users."))
       ->setTranslatable(TRUE);
 
     $fields['homepage'] = BaseFieldDefinition::create('uri')
diff --git a/core/modules/comment/src/Plugin/Field/FieldFormatter/AuthorNameFormatter.php b/core/modules/comment/src/Plugin/Field/FieldFormatter/AuthorNameFormatter.php
index 1d10dd0..6053fda 100644
--- a/core/modules/comment/src/Plugin/Field/FieldFormatter/AuthorNameFormatter.php
+++ b/core/modules/comment/src/Plugin/Field/FieldFormatter/AuthorNameFormatter.php
@@ -44,6 +44,17 @@ public function viewElements(FieldItemListInterface $items, $langcode) {
       );
     }
 
+    if (count($items)==0) {
+      $comment = $items->getEntity();
+      $account = $comment->getOwner();
+      $elements[0] = array(
+        '#theme' => 'username',
+        '#account' => $account,
+        '#cache' => array(
+          'tags' => $account->getCacheTags() + $comment->getCacheTags(),
+        ),
+      );
+    }
     return $elements;
   }
 
diff --git a/core/modules/comment/src/Tests/CommentInterfaceTest.php b/core/modules/comment/src/Tests/CommentInterfaceTest.php
index 4b326a6..36d01d6 100644
--- a/core/modules/comment/src/Tests/CommentInterfaceTest.php
+++ b/core/modules/comment/src/Tests/CommentInterfaceTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\comment\Tests;
 
+use Drupal\Component\Render\FormattableMarkup;
 use Drupal\comment\CommentManagerInterface;
 use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
 use Drupal\comment\Entity\Comment;
@@ -216,6 +217,127 @@ public function testCommentInterface() {
   }
 
   /**
+   * Test the effect of editing a comment.
+   */
+  public function testCommentEdit() {
+    $users = array(
+      'admin user' => $this->adminUser,
+      'web user' => $this->webUser,
+    );
+
+    foreach ($users as $user_key => $user) {
+      /** @var \Drupal\user\UserInterface $user */
+      $user_placeholder = array('@user' => $user_key);
+
+      $this->drupalLogin($user);
+      $subject_text = $this->randomMachineName();
+      $comment_text = $this->randomMachineName();
+      $new_comment_text = $this->randomMachineName();
+      $new_subject_text = $this->randomMachineName();
+      $this->setCommentSubject(TRUE);
+      $this->setCommentPreview(DRUPAL_DISABLED);
+
+      // Create a comment and make sure it is stored correctly.
+      $comment = $this->postComment($this->node, $comment_text, $subject_text, TRUE);
+      $this->assertTrue($this->commentExists($comment), 'Comment found.');
+      $this->assertNull($comment->get('name')->value, new FormattableMarkup('Comment author name stored in database is NULL for @user.', $user_placeholder));
+      $this->assertNull($comment->get('mail')->value, new FormattableMarkup('Comment author email stored in database is NULL for @user.', $user_placeholder));
+      $this->assertEqual($comment->getAuthorName(), $user->getAccountName(), new FormattableMarkup('Comment author name returned by API is @user.', $user_placeholder));
+      $this->assertEqual($comment->getOwnerId(), $user->id(), new FormattableMarkup('Comment owner is @user.', $user_placeholder));
+
+      // Test editing the comment to make sure the user information stays intact.
+      $this->drupalGet('comment/' . $comment->id() . '/edit');
+      $new_comment = $this->postComment(NULL, $new_comment_text, $new_subject_text, $user->getAccountName() . ' (' . $user->id() . ')');
+      $this->assertNull($new_comment->get('name')->value, 'Comment author name stored in database is still NULL after edit.');
+      $this->assertNull($new_comment->get('mail')->value, 'Comment author name stored in database is still NULL after edit.');
+      $this->assertTrue($new_comment->getAuthorName() == $user->getAccountName(), 'Comment author name from API not changed by edit.');
+      $this->assertTrue($new_comment->getOwnerId() == $user->id(), 'Comment owner not changed by edit.');
+
+      $this->assertEqual($comment->id(), $new_comment->id(), 'Id of original comment and edited comment are the same.');
+      // We don't need to check the updated body/subject because postComment() does.
+
+      $this->drupalLogout();
+    }
+
+    // Now create an anonymous comment and test editing it as an admin user.
+    // Do this for the different valid scenarios of
+    $contact_valid_options = array(
+      array(
+        'level' => COMMENT_ANONYMOUS_MAYNOT_CONTACT,
+        'provide_email' => FALSE,
+        'label' => 'COMMENT_ANONYMOUS_MAYNOT_CONTACT',
+      ),
+      array(
+        'level' => COMMENT_ANONYMOUS_MAY_CONTACT,
+        'provide_email' => FALSE,
+        'label' => 'COMMENT_ANONYMOUS_MAY_CONTACT - no email',
+      ),
+      array(
+        'level' => COMMENT_ANONYMOUS_MAY_CONTACT,
+        'provide_email' => TRUE,
+        'label' => 'COMMENT_ANONYMOUS_MAY_CONTACT - email',
+      ),
+      array(
+        'level' => COMMENT_ANONYMOUS_MUST_CONTACT,
+        'provide_email' => TRUE,
+        'label' => 'COMMENT_ANONYMOUS_MUST_CONTACT',
+      ),
+    );
+    foreach ($contact_valid_options as $option_set) {
+      $provide_email = $option_set['provide_email'];
+      $level = $option_set['level'];
+      $label = array('@level' => $option_set['label']);
+
+      $subject_text = $this->randomMachineName();
+      $comment_text = $this->randomMachineName();
+      $new_comment_text = $this->randomMachineName();
+      $new_subject_text = $this->randomMachineName();
+      $anon_name = $this->randomMachineName();
+      $anon_email = 'anon@example.com';
+      $anon_contact_info = array(
+        'name' => $anon_name,
+      );
+      if ($provide_email) {
+        $anon_contact_info['mail'] = $anon_email;
+      }
+      else {
+        $anon_email = '';
+      }
+
+      $this->setCommentAnonymous($level);
+      user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, array(
+        'access content',
+        'access comments',
+        'post comments',
+        'skip comment approval'
+      ));
+
+      $anonymous_comment = $this->postComment($this->node, $comment_text, $subject_text, $anon_contact_info);
+      $this->assertTrue($this->commentExists($anonymous_comment), new FormattableMarkup('Comment found (@level).', $label));
+
+      if (isset($anonymous_comment)) {
+        $this->assertEqual($anonymous_comment->getOwnerId(), 0, 'Anonymous comment has owner id of zero.');
+        $this->assertEqual($anonymous_comment->get('name')->value, $anon_name, 'Anon comment author in database is the value submitted.');
+        $this->assertEqual($anonymous_comment->getAuthorName(), $anon_name, 'Anon author name from API is the value stored.');
+        $email_assert_message = new FormattableMarkup('Anon comment email in database is the value submitted (with settings @level).', $label);
+        $this->assertEqual($anonymous_comment->get('mail')->value, $anon_email, $email_assert_message);
+
+        $this->drupalLogin($this->adminUser);
+        // Test editing the comment to make sure the user information stays intact.
+        $this->drupalGet('comment/' . $anonymous_comment->id() . '/edit');
+        $new_anon_comment = $this->postComment(NULL, $new_comment_text, $new_subject_text);
+        $this->assertEqual($new_anon_comment->getOwnerId(), 0, 'Edited comment has owner id of zero.');
+        $this->assertEqual($new_anon_comment->get('name')->value, $anon_name, 'Edited comment author in database is unchanged.');
+        $this->assertEqual($new_anon_comment->getAuthorName(), $anon_name, 'Anon author name from API is unchanged.');
+
+        $this->assertEqual($anonymous_comment->id(), $new_anon_comment->id(), 'Edited comment id is the same as the original.');
+
+        $this->drupalLogout();
+      }
+    }
+  }
+
+  /**
    * Test that the subject is automatically filled if disabled or left blank.
    *
    * When the subject field is blank or disabled, the first 29 characters of the
diff --git a/core/modules/comment/tests/src/Unit/Entity/CommentLockTest.php b/core/modules/comment/tests/src/Unit/Entity/CommentLockTest.php
index 021e7b6..564627d 100644
--- a/core/modules/comment/tests/src/Unit/Entity/CommentLockTest.php
+++ b/core/modules/comment/tests/src/Unit/Entity/CommentLockTest.php
@@ -73,6 +73,14 @@ public function testLocks() {
       ->method('getThread')
       ->will($this->returnValue(''));
 
+    $anon_user = $this->getMock('Drupal\Core\Session\AccountInterface');
+    $anon_user->expects($this->any())
+      ->method('isAnonymous')
+      ->will($this->returnValue(TRUE));
+    $comment->expects($this->any())
+      ->method('getOwner')
+      ->will($this->returnValue($anon_user));
+
     $parent_entity = $this->getMock('\Drupal\Core\Entity\ContentEntityInterface');
     $parent_entity->expects($this->atLeastOnce())
       ->method('getCacheTagsToInvalidate')
diff --git a/core/modules/hal/src/Tests/EntityTest.php b/core/modules/hal/src/Tests/EntityTest.php
index 6301fb0..7fcf6e4 100644
--- a/core/modules/hal/src/Tests/EntityTest.php
+++ b/core/modules/hal/src/Tests/EntityTest.php
@@ -198,8 +198,8 @@ public function testComment() {
 
     $original_values = $comment->toArray();
     // cid will not exist and hostname will always be denied view access.
-    // No value will exist for name as this is only for anonymous users.
-    unset($original_values['cid'], $original_values['hostname'], $original_values['name']);
+    // No value will exist for name or mail as these are only for anonymous users.
+    unset($original_values['cid'], $original_values['hostname'], $original_values['name'], $original_values['mail']);
 
     $normalized = $this->serializer->normalize($comment, $this->format, ['account' => $account]);
 
