Same name and namespace in other branches
  1. 10 core/modules/tracker/tracker.module \_tracker_calculate_changed()
  2. 8.9.x core/modules/tracker/tracker.module \_tracker_calculate_changed()
  3. 9 core/modules/tracker/tracker.module \_tracker_calculate_changed()

Determines the max timestamp between $node->changed and the last comment.

Parameters

$nid: A node ID.

Return value

The $node->changed timestamp, or most recent comment timestamp, whichever is the greatest.

2 calls to _tracker_calculate_changed()
tracker_cron in modules/tracker/tracker.module
Implements hook_cron().
_tracker_remove in modules/tracker/tracker.module
Cleans up indexed data when nodes or comments are removed.

File

modules/tracker/tracker.module, line 297
Tracks recent content posted by a user or users.

Code

function _tracker_calculate_changed($nid) {
  $changed = db_query('SELECT changed FROM {node} WHERE nid = :nid', array(
    ':nid' => $nid,
  ), array(
    'target' => 'slave',
  ))
    ->fetchField();
  $latest_comment = db_query_range('SELECT cid, changed FROM {comment} WHERE nid = :nid AND status = :status ORDER BY changed DESC', 0, 1, array(
    ':nid' => $nid,
    ':status' => COMMENT_PUBLISHED,
  ), array(
    'target' => 'slave',
  ))
    ->fetchObject();
  if ($latest_comment && $latest_comment->changed > $changed) {
    $changed = $latest_comment->changed;
  }
  return $changed;
}