+ // 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);
+ }