diff --git a/core/modules/tracker/tracker.module b/core/modules/tracker/tracker.module index ce7f399..d62126b 100644 --- a/core/modules/tracker/tracker.module +++ b/core/modules/tracker/tracker.module @@ -294,9 +294,11 @@ function _tracker_add($nid, $uid, $changed) { */ function _tracker_calculate_changed($node) { $changed = $node->getChangedTime(); - $latest_comment = \Drupal::service('comment.statistics')->read(array($node), 'node', FALSE); - if ($latest_comment && $latest_comment->last_comment_timestamp > $changed) { - $changed = $latest_comment->last_comment_timestamp; + if (\Drupal::hasService('comment.statistics')) { + $latest_comment = \Drupal::service('comment.statistics')->read(array($node), 'node', FALSE); + if ($latest_comment && $latest_comment->last_comment_timestamp > $changed) { + $changed = $latest_comment->last_comment_timestamp; + } } return $changed; } diff --git a/core/modules/tracker/tracker.pages.inc b/core/modules/tracker/tracker.pages.inc index 93e33ea..42fc160 100644 --- a/core/modules/tracker/tracker.pages.inc +++ b/core/modules/tracker/tracker.pages.inc @@ -48,13 +48,13 @@ function tracker_page($account = NULL) { $cache_tags = []; $rows = []; - $comment_module = \Drupal::moduleHandler()->moduleExists('comment'); + $has_comment_stats_service = \Drupal::hasService('comment.statistics'); if (!empty($tracker_data)) { // Load nodes into an array with the same order as $tracker_data. $nodes = Node::loadMultiple(array_keys($tracker_data)); // Enrich the node data. - if ($comment_module) { + if ($has_comment_stats_service) { $result = \Drupal::service('comment.statistics') ->read($nodes, 'node', FALSE); foreach ($result as $statistics) { @@ -86,7 +86,7 @@ function tracker_page($account = NULL) { // Determine the number of comments. $comments = 0; - if ($comment_module && $node->comment_count) { + if ($has_comment_stats_service && $node->comment_count) { $comments = $node->comment_count; } @@ -108,7 +108,7 @@ function tracker_page($account = NULL) { ), ), ); - if ($comment_module) { + if ($has_comment_stats_service) { $row['comments'] = [ 'class' => ['comments'], 'data' => $comments, @@ -135,7 +135,7 @@ function tracker_page($account = NULL) { $page['tracker'] = array( '#rows' => $rows, - '#header' => $comment_module ? [t('Type'), t('Title'), t('Author'), t('Comments'), t('Last updated')] : [t('Type'), t('Title'), t('Author'), t('Last updated')], + '#header' => $has_comment_stats_service ? [t('Type'), t('Title'), t('Author'), t('Comments'), t('Last updated')] : [t('Type'), t('Title'), t('Author'), t('Last updated')], '#type' => 'table', '#empty' => t('No content available.'), );