diff -u b/core/modules/comment/comment.module b/core/modules/comment/comment.module --- b/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -1265,7 +1265,7 @@ } if (!empty($account) && $account->isAuthenticated()) { - $comment->setOwnerId($account->id()); + $comment->setOwner($account); $comment->name->value = check_plain($account->getUsername()); } else { diff -u b/core/modules/comment/comment.tokens.inc b/core/modules/comment/comment.tokens.inc --- b/core/modules/comment/comment.tokens.inc +++ b/core/modules/comment/comment.tokens.inc @@ -148,7 +148,9 @@ break; case 'mail': - if ($comment->getOwnerId() != 0) { + // Check identicality, because getOwnerId() returns NULL if there is no + // ID, which evaluates to 0. + if ($comment->getOwnerId() !== 0) { $mail = $comment->getOwner()->getEmail(); } else { diff -u b/core/modules/comment/lib/Drupal/comment/CommentFormController.php b/core/modules/comment/lib/Drupal/comment/CommentFormController.php --- b/core/modules/comment/lib/Drupal/comment/CommentFormController.php +++ b/core/modules/comment/lib/Drupal/comment/CommentFormController.php @@ -321,7 +321,7 @@ // @todo Too fragile. Should be prepared and stored in comment_form() // already. if (!$comment->is_anonymous && !empty($comment->name->value) && ($account = user_load_by_name($comment->name->value))) { - $comment->setOwnerId($account->id()); + $comment->setOwner($account); } // If the comment was posted by an anonymous user and no author name was // required, use "Anonymous" by default. diff -u b/core/modules/user/lib/Drupal/user/EntityOwnerInterface.php b/core/modules/user/lib/Drupal/user/EntityOwnerInterface.php --- b/core/modules/user/lib/Drupal/user/EntityOwnerInterface.php +++ b/core/modules/user/lib/Drupal/user/EntityOwnerInterface.php @@ -9,6 +9,11 @@ /** * Defines a common interface for entities that have an owner. + * + * An owner is someone who has primary control over an entity, similar to + * owners in Unix file system access. This may or may not be the entity's + * original author. The owner may also have less permissions than other users, + * such as administrators. */ interface EntityOwnerInterface {