diff --git a/core/modules/tracker/tracker.module b/core/modules/tracker/tracker.module index 3a6919e..fba29f8 100644 --- a/core/modules/tracker/tracker.module +++ b/core/modules/tracker/tracker.module @@ -87,36 +87,30 @@ function tracker_cron() { )) ->execute(); - if ($node->isPublished()) { - // Insert the user-level data for the commenters (except if a commenter - // is the node's author). - - // 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 ($result as $row) { - if ($row['uid'] != $node->getOwnerId()) { - $do_insert = TRUE; - $query->fields(array( - 'uid' => $row['uid'], - 'nid' => $nid, - 'published' => CommentInterface::PUBLISHED, - 'changed' => $changed, - )); - } - } - if ($do_insert) { - $query->execute(); - } + // Insert the user-level data for the commenters (except if a commenter + // is the node's author). + + // 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->id()) + ->condition('uid', $node->getOwnerId(), '<>') + ->condition('status', CommentInterface::PUBLISHED) + ->groupBy('uid') + ->execute(); + if ($result) { + $query = db_insert('tracker_user'); + foreach ($result as $row) { + $query->fields(array( + 'uid' => $row['uid'], + 'nid' => $nid, + 'published' => CommentInterface::PUBLISHED, + 'changed' => $changed, + )); } + $query->execute(); } // Note that we have indexed at least one node.