diff --git a/core/modules/book/lib/Drupal/book/BookManager.php b/core/modules/book/lib/Drupal/book/BookManager.php index 144cc94..abd1820 100644 --- a/core/modules/book/lib/Drupal/book/BookManager.php +++ b/core/modules/book/lib/Drupal/book/BookManager.php @@ -68,7 +68,7 @@ protected function loadBooks() { $nids = $this->database->query("SELECT DISTINCT(bid) FROM {book}")->fetchCol(); if ($nids) { - $query = db_select('book', 'b', array('fetch' => \PDO::FETCH_ASSOC)); + $query = $this->database->select('book', 'b', array('fetch' => \PDO::FETCH_ASSOC)); $query->join('menu_links', 'ml', 'b.mlid = ml.mlid'); $query->fields('b'); $query->fields('ml'); diff --git a/core/modules/comment/comment.admin.inc b/core/modules/comment/comment.admin.inc index cb62a60..84e61f6 100644 --- a/core/modules/comment/comment.admin.inc +++ b/core/modules/comment/comment.admin.inc @@ -91,15 +91,16 @@ function comment_admin_overview($form, &$form_state, $arg) { ->orderByHeader($header) ->execute(); + $nids = array(); $cids = array(); // We collect a sorted list of node_titles during the query to attach to the // comments later. foreach ($result as $row) { - $node = node_load($row->nid); + $nids[] = $row->nid; $cids[] = $row->cid; - $node_titles[] = $node->label(); } + $node = node_load_multiple($nids); $comments = comment_load_multiple($cids); // Build a table listing the appropriate comments. @@ -109,7 +110,7 @@ function comment_admin_overview($form, &$form_state, $arg) { foreach ($comments as $comment) { // Remove the first node title from the node_titles array and attach to // the comment. - $node_title = array_shift($node_titles); + $node_title = $comment->nid->entity->label(); $options[$comment->id()] = array( 'subject' => array( 'data' => array( diff --git a/core/modules/comment/comment.install b/core/modules/comment/comment.install index 57b0c3b..9640304 100644 --- a/core/modules/comment/comment.install +++ b/core/modules/comment/comment.install @@ -37,9 +37,8 @@ function comment_uninstall() { */ function comment_enable() { // Insert records into the node_comment_statistics for nodes that are missing. - // TODO Add support for multilingual properties. $query = db_select('node_field_data', 'n'); - $query->leftJoin('node_comment_statistics', 'ncs', 'ncs.nid = n.nid'); + $query->leftJoin('node_comment_statistics', 'ncs', 'ncs.nid = n.nid AND n.default_langcode = 1'); $query->addField('n', 'created', 'last_comment_timestamp'); $query->addField('n', 'uid', 'last_comment_uid'); $query->addField('n', 'nid'); diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index 32f89ca..795fc65 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -466,6 +466,9 @@ function comment_get_recent($number = 10) { ->fields('c') ->condition('c.status', COMMENT_PUBLISHED) ->condition('n.status', NODE_PUBLISHED) + // @todo This should be actually filtering on the desired node status field + // language and just fall back to the default language. + ->condition('n.default_langcode', 1) ->orderBy('c.created', 'DESC') // Additionally order by cid to ensure that comments with the same timestamp // are returned in the exact order posted. diff --git a/core/modules/forum/forum.module b/core/modules/forum/forum.module index f142da5..c234645 100644 --- a/core/modules/forum/forum.module +++ b/core/modules/forum/forum.module @@ -749,6 +749,9 @@ function forum_forum_load($tid = NULL) { $counts = $query ->fields('f', array('tid')) ->condition('n.status', 1) + // @todo This should be actually filtering on the desired node status + // field language and just fall back to the default language. + ->condition('n.default_langcode', 1) ->groupBy('tid') ->addTag('node_access') ->execute() @@ -781,6 +784,9 @@ function forum_forum_load($tid = NULL) { $topic = $query ->fields('ncs', array('last_comment_timestamp', 'last_comment_uid')) ->condition('n.status', 1) + // @todo This should be actually filtering on the desired node status + // field language and just fall back to the default language. + ->condition('n.default_langcode', 1) ->orderBy('last_comment_timestamp', 'DESC') ->range(0, 1) ->addTag('node_access') @@ -825,6 +831,9 @@ function _forum_topics_unread($term, $uid) { $query->addExpression('COUNT(n.nid)', 'count'); return $query ->condition('status', 1) + // @todo This should be actually filtering on the desired node status field + // language and just fall back to the default language. + ->condition('n.default_langcode', 1) ->condition('n.created', HISTORY_READ_LIMIT, '>') ->isNull('h.nid') ->addTag('node_access') @@ -913,7 +922,9 @@ function forum_get_topics($tid, $sortby, $forum_per_page) { ->orderBy('f.sticky', 'DESC') ->orderByHeader($forum_topic_list_header) ->condition('n.nid', $nids) - ->groupBy('n.nid'); + // @todo This should be actually filtering on the desired node status + // field language and just fall back to the default language. + ->condition('n.default_langcode', 1); $result = array(); foreach ($query->execute() as $row) { @@ -1293,7 +1304,9 @@ function _forum_update_forum_index($nid) { } else { // Comments do not exist. - $node = db_query('SELECT uid, created FROM {node_field_data} WHERE nid = :nid LIMIT 1', array(':nid' => $nid))->fetchObject(); + // @todo This should be actually filtering on the desired node status field + // language and just fall back to the default language. + $node = db_query('SELECT uid, created FROM {node_field_data} WHERE nid = :nid AND default_langcode = 1', array(':nid' => $nid))->fetchObject(); db_update('forum_index') ->fields( array( 'comment_count' => 0,