diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index fc6b73e..2d465ec 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -1480,7 +1480,7 @@ function comment_num_new($nid, $timestamp = 0) { if ($user->uid && module_exists('history')) { // Retrieve the timestamp at which the current user last viewed this node. if (!$timestamp) { - $timestamp = history_node_last_viewed($nid); + $timestamp = history_read($nid); } $timestamp = ($timestamp > HISTORY_READ_LIMIT ? $timestamp : HISTORY_READ_LIMIT); diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentLinksTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentLinksTest.php index c1eff57..d049aa3 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentLinksTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentLinksTest.php @@ -141,8 +141,8 @@ function setEnvironment(array $info) { comment_save($comment); $this->comment = $comment; - // comment_num_new() relies on history_node_last_viewed(), so ensure - // that no one has seen the node of this comment. + // comment_num_new() relies on history_read(), so ensure that no one has + // seen the node of this comment. db_delete('history')->condition('nid', $this->node->nid)->execute(); } else { diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentTokenReplaceTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentTokenReplaceTest.php index 46db533..34674e8 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentTokenReplaceTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentTokenReplaceTest.php @@ -11,7 +11,6 @@ * Tests comment token replacement in strings. */ class CommentTokenReplaceTest extends CommentTestBase { - public static function getInfo() { return array( 'name' => 'Comment token replacement', diff --git a/core/modules/history/history.module b/core/modules/history/history.module index 953da8b..7f87805 100644 --- a/core/modules/history/history.module +++ b/core/modules/history/history.module @@ -5,7 +5,7 @@ * Records which users has read which content. * * @todo - * - Generic helper for _forum_user_last_visit() + history_node_last_viewed(). + * - Generic helper for _forum_user_last_visit() + history_read(). * - Generic helper for node_mark(). */ @@ -37,7 +37,7 @@ function history_cron() { * (optional) The user account to update the history for. Defaults to the * current user. */ -function history_update($nid, $account = NULL) { +function history_write($nid, $account = NULL) { global $user; if (!isset($account)) { @@ -78,6 +78,15 @@ function history_user_cancel($edit, $account, $method) { } /** + * Implements hook_user_delete(). + */ +function history_user_delete($account) { + db_delete('history') + ->condition('uid', $account->uid) + ->execute(); +} + +/** * Retrieves the timestamp for the current user's last view of a specified node. * * @param int $nid @@ -87,7 +96,7 @@ function history_user_cancel($edit, $account, $method) { * If a node has been previously viewed by the user, the timestamp in seconds * of when the last view occurred; otherwise, zero. */ -function history_node_last_viewed($nid) { +function history_read($nid) { global $user; $history = &drupal_static(__FUNCTION__, array()); diff --git a/core/modules/node/node.module b/core/modules/node/node.module index 014d73b..a4c06cf 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -298,12 +298,11 @@ function node_mark($nid, $timestamp) { global $user; $cache = &drupal_static(__FUNCTION__, array()); - $history_module_enabled = module_exists('history'); - if (!$user->uid || !$history_module_enabled) { + if (!$user->uid || !module_exists('history')) { return MARK_READ; } - if (!isset($cache[$nid]) && $history_module_enabled) { - $cache[$nid] = history_node_last_viewed($nid); + if (!isset($cache[$nid])) { + $cache[$nid] = history_read($nid); } if ($cache[$nid] == 0 && $timestamp > HISTORY_READ_LIMIT) { return MARK_NEW; @@ -1058,7 +1057,7 @@ function node_show(Node $node, $message = FALSE) { // Update the history table, stating that this user viewed this node. if (module_exists('history')) { - history_update($node->nid); + history_write($node->nid); } return $nodes;