diff --git a/core/modules/comment/src/CommentStorage.php b/core/modules/comment/src/CommentStorage.php index 0439678..9639d59 100644 --- a/core/modules/comment/src/CommentStorage.php +++ b/core/modules/comment/src/CommentStorage.php @@ -203,18 +203,6 @@ public function getChildCids(array $comments) { /** * {@inheritdoc} - */ - public function getCommentingUserIds(EntityInterface $entity) { - return $this->database->query('SELECT DISTINCT c.uid FROM {comment_field_data} c WHERE entity_id = :entity_id - AND entity_type=:entity_type - AND default_langcode = 1', array( - ':entity_id' => $entity->id(), - ':entity_type' => $entity->getEntityTypeId() - ))->fetchCol(); - } - - /** - * {@inheritdoc} * * To display threaded comments in the correct order we keep a 'thread' field * and order by that value. This field keeps this data in diff --git a/core/modules/comment/src/CommentStorageInterface.php b/core/modules/comment/src/CommentStorageInterface.php index 2b38220..d3f15a9 100644 --- a/core/modules/comment/src/CommentStorageInterface.php +++ b/core/modules/comment/src/CommentStorageInterface.php @@ -86,17 +86,6 @@ public function getDisplayOrdinal(CommentInterface $comment, $comment_mode, $div public function getChildCids(array $comments); /** - * Gets the ids of users that commented on a given parent entity. - * - * @param \Drupal\Core\Entity\EntityInterface $entity - * User object. - * - * @return int[] - * Array of user ids. - */ - public function getCommentingUserIds(EntityInterface $entity); - - /** * Retrieves comments for a thread, sorted in an order suitable for display. * * @param \Drupal\Core\Entity\EntityInterface $entity diff --git a/core/modules/tracker/tracker.module b/core/modules/tracker/tracker.module index d3d1612..3a6919e 100644 --- a/core/modules/tracker/tracker.module +++ b/core/modules/tracker/tracker.module @@ -90,20 +90,32 @@ function tracker_cron() { if ($node->isPublished()) { // Insert the user-level data for the commenters (except if a commenter // is the node's author). - $uids = \Drupal::entityManager()->getStorage('comment')->getCommentingUserIds($node); - if ($uids) { + + // Get unique user IDs via entityQueryAggregate because it's the easiest + // database agnostic way. We don't actually care about the comments here + // so don't add an aggregate field. + $result = \Drupal::entityQueryAggregate('comment') + ->condition('entity_type', 'node') + ->condition('entity_id', $node->getOwnerId()) + ->groupBy('uid') + ->execute(); + if ($result) { + $do_insert = FALSE; $query = db_insert('tracker_user'); - foreach ($uids as $uid) { - if ($uid != $node->getOwnerId()) { + foreach ($result as $row) { + if ($row['uid'] != $node->getOwnerId()) { + $do_insert = TRUE; $query->fields(array( - 'uid' => $uid, + 'uid' => $row['uid'], 'nid' => $nid, 'published' => CommentInterface::PUBLISHED, 'changed' => $changed, )); } } - $query->execute(); + if ($do_insert) { + $query->execute(); + } } }