function _tracker_calculate_changed

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

Picks the most recent timestamp between node changed and the last comment.

@todo Check if we should introduce 'language context' here, because the callers may need different timestamps depending on the users' language?

Parameters

\Drupal\node\NodeInterface $node: The node entity.

Return value

int The node changed timestamp, or most recent comment timestamp, whichever is the greatest.

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

File

core/modules/tracker/tracker.module, line 266

Code

function _tracker_calculate_changed($node) {
    $changed = $node->getChangedTime();
    $latest_comment = \Drupal::service('comment.statistics')->read([
        $node,
    ], 'node', FALSE);
    if ($latest_comment && $latest_comment->last_comment_timestamp > $changed) {
        $changed = $latest_comment->last_comment_timestamp;
    }
    return $changed;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.