diff --git a/core/lib/Drupal/Core/Entity/EntityBCDecorator.php b/core/lib/Drupal/Core/Entity/EntityBCDecorator.php index 94f5b4f..d19d5b8 100644 --- a/core/lib/Drupal/Core/Entity/EntityBCDecorator.php +++ b/core/lib/Drupal/Core/Entity/EntityBCDecorator.php @@ -120,7 +120,7 @@ public function __unset($name) { /** * Forwards the call to the decorated entity. */ - public function access(\Drupal\user\User $account = NULL) { + public function access($operation = 'view', \Drupal\user\Plugin\Core\Entity\User $account = NULL) { return $this->decorated->access($account); } diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index 4ef215d..2d7e022 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -1642,16 +1642,14 @@ function comment_preprocess_block(&$variables) { * This helper handles anonymous authors in addition to registered comment * authors. * - * @return \Drupal\user\User + * @return \Drupal\user\Plugin\Core\Entity\User * A user account, for use with theme_username() or the user_picture template. */ function comment_prepare_author(Comment $comment) { - // This has been pre-populated by user_attach_accounts(). - $account = $comment->account; - // For anonymous accounts copy over the information recorded in the comment. - if (!$account->uid) { - $account->name = $comment->name->value; - $account->homepage = $comment->homepage->value; + // The account has been pre-loaded by CommentRenderController::buildContent(). + $account = $comment->uid->entity; + if (!$account) { + $account = entity_create('user', array('uid' => 0, 'name' => $comment->name->value, 'homepage' => $comment->homepage->value)); } return $account; } diff --git a/core/modules/comment/lib/Drupal/comment/CommentRenderController.php b/core/modules/comment/lib/Drupal/comment/CommentRenderController.php index 5bd9ccb..bc35285 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentRenderController.php +++ b/core/modules/comment/lib/Drupal/comment/CommentRenderController.php @@ -27,8 +27,12 @@ public function buildContent(array $entities = array(), $view_mode = 'full', $la return $return; } - // Attach user account. - user_attach_accounts($entities); + // Pre-load associated users into cache to leverage multiple loading. + $uids = array(); + foreach ($entities as $entity) { + $uids[] = $entity->uid->value; + } + user_load_multiple(array_unique($uids)); parent::buildContent($entities, $view_mode, $langcode);