diff --git a/core/modules/comment/lib/Drupal/comment/Plugin/views/field/NodeNewComments.php b/core/modules/comment/lib/Drupal/comment/Plugin/views/field/NodeNewComments.php index a0f7f78..6531d8d 100644 --- a/core/modules/comment/lib/Drupal/comment/Plugin/views/field/NodeNewComments.php +++ b/core/modules/comment/lib/Drupal/comment/Plugin/views/field/NodeNewComments.php @@ -83,7 +83,8 @@ function pre_render(&$values) { $query->addField('n', 'nid'); $query->innerJoin('comment', 'c', 'n.nid = c.nid'); $query->addExpression('COUNT(c.cid)', 'num_comments'); - $query->leftJoin('history', 'h', 'h.nid = n.nid'); + $query->leftJoin('history', 'h', 'h.entity_id = n.nid'); + $query->condition('h.entity_type', 'node'); $query->condition('n.nid', $nids); $query->where('c.changed > GREATEST(COALESCE(h.timestamp, :timestamp), :timestamp)', array(':timestamp' => HISTORY_READ_LIMIT)); $query->condition('c.status', COMMENT_PUBLISHED); diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentLinksTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentLinksTest.php index 91cab48..752daed 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentLinksTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentLinksTest.php @@ -143,7 +143,10 @@ function setEnvironment(array $info) { // 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(); + db_delete('history') + ->condition('entity_id', $this->node->nid) + ->condition('entity_type', 'node') + ->execute(); } else { $cids = db_query("SELECT cid FROM {comment}")->fetchCol(); diff --git a/core/modules/forum/forum.module b/core/modules/forum/forum.module index 8b35c3e..7e2dabd 100644 --- a/core/modules/forum/forum.module +++ b/core/modules/forum/forum.module @@ -811,12 +811,12 @@ function forum_forum_load($tid = NULL) { function _forum_topics_unread($term, $uid) { $query = db_select('node', 'n'); $query->join('forum', 'f', 'n.vid = f.vid AND f.tid = :tid', array(':tid' => $term)); - $query->leftJoin('history', 'h', 'n.nid = h.nid AND h.uid = :uid', array(':uid' => $uid)); + $query->leftJoin('history', 'h', "n.nid = h.entity_id AND h.entity_type = 'node' AND h.uid = :uid", array(':uid' => $uid)); $query->addExpression('COUNT(n.nid)', 'count'); return $query ->condition('status', 1) ->condition('n.created', HISTORY_READ_LIMIT, '>') - ->isNull('h.nid') + ->isNull('h.entity_id') ->addTag('node_access') ->execute() ->fetchField(); diff --git a/core/modules/history/history.install b/core/modules/history/history.install index 0117e49..782ba03 100644 --- a/core/modules/history/history.install +++ b/core/modules/history/history.install @@ -55,6 +55,16 @@ function history_schema() { } /** + * Implements hook_update_dependencies(). + */ +function history_update_dependencies() { + // Convert after *id fields unsigned. + $dependencies['history'][8000] = array( + 'node' => 8005, + ); +} + +/** * Upgrades {history} to be used for any entity type. */ function history_update_8000() {