1 node.module node_tag_new($node = NULL, $save_for_later = FALSE)

Updates the 'last viewed' timestamp of the specified node for current user.

@since 1.10 $save_for_later parameter added.


Node $node: A node entity.

bool $save_for_later: Save the given node ID to save its marking for at the end of the request.


core/modules/node/node.module, line 290
The core module that allows content to be submitted to the site.


function node_tag_new($node = NULL, $save_for_later = FALSE) {
  $nids_viewed = &backdrop_static(__FUNCTION__, array());
  if ($node) {
    $nids_viewed[] = $node->nid;

  // Node IDs saved for later are then actually updated in a shutdown function.
  if ($save_for_later || empty($nids_viewed)) {

  global $user;
  if ($user->uid) {
    foreach ($nids_viewed as $nid) {
          'uid' => $user->uid,
          'nid' => $nid,
        ->fields(array('timestamp' => REQUEST_TIME))

  // Clear out the saved list so we don't update the same nodes again..
  $nids_viewed = array();