core/modules/comment/comment.test | 6 +++--- core/modules/forum/forum.module | 16 +++++++++++++--- core/modules/node/node.module | 7 +++++-- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/core/modules/comment/comment.test b/core/modules/comment/comment.test index 4909337..bdca0cf 100644 --- a/core/modules/comment/comment.test +++ b/core/modules/comment/comment.test @@ -21,8 +21,8 @@ class CommentHelperCase extends DrupalWebTestCase { /** * Posts a comment. * - * @param Node $node - * Node to post comment on. + * @param Node|NULL $node + * Node to post comment on or NULL to post to the previusly loaded page. * @param $comment * Comment body. * @param $subject @@ -31,7 +31,7 @@ class CommentHelperCase extends DrupalWebTestCase { * Set to NULL for no contact info, TRUE to ignore success checking, and * array of values to set contact info. */ - function postComment(Node $node, $comment, $subject = '', $contact = NULL) { + function postComment(Node $node = NULL, $comment, $subject = '', $contact = NULL) { $langcode = LANGUAGE_NONE; $edit = array(); $edit['comment_body[' . $langcode . '][0][value]'] = $comment; diff --git a/core/modules/forum/forum.module b/core/modules/forum/forum.module index 39082b9..7adaa38 100644 --- a/core/modules/forum/forum.module +++ b/core/modules/forum/forum.module @@ -893,9 +893,10 @@ function forum_get_topics($tid, $sortby, $forum_per_page) { $nids[] = $record->nid; } if ($nids) { + $nodes = node_load_multiple($nids); + $query = db_select('node', 'n')->extend('TableSort'); - $query->fields('n', array('title', 'nid', 'type', 'sticky', 'created', 'uid')); - $query->addField('n', 'comment', 'comment_mode'); + $query->fields('n', array('nid')); $query->join('node_comment_statistics', 'ncs', 'n.nid = ncs.nid'); $query->fields('ncs', array('cid', 'last_comment_uid', 'last_comment_timestamp', 'comment_count')); @@ -915,7 +916,16 @@ function forum_get_topics($tid, $sortby, $forum_per_page) { ->orderByHeader($forum_topic_list_header) ->condition('n.nid', $nids); - $result = $query->execute(); + $result = array(); + foreach ($query->execute() as $row) { + $topic = $nodes[$row->nid]; + $topic->comment_mode = $topic->comment; + + foreach ($row as $key => $value) { + $topic->{$key} = $value; + } + $result[] = $topic; + } } else { $result = array(); diff --git a/core/modules/node/node.module b/core/modules/node/node.module index eaa5783..a89035c 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -2556,8 +2556,12 @@ function node_update_index() { $limit = (int)variable_get('search_cron_limit', 100); $result = db_query_range("SELECT n.nid FROM {node} n LEFT JOIN {search_dataset} d ON d.type = 'node' AND d.sid = n.nid WHERE d.sid IS NULL OR d.reindex <> 0 ORDER BY d.reindex ASC, n.nid ASC", 0, $limit, array(), array('target' => 'slave')); + $nids = $result->fetchCol(); + if (!$nids) { + return; + } - foreach ($result as $node) { + foreach (node_load_multiple($nids) as $node) { _node_index_node($node); } } @@ -2569,7 +2573,6 @@ function node_update_index() { * The node to index. */ function _node_index_node(Node $node) { - $node = node_load($node->nid); // Save the changed time of the most recent indexed node, for the search // results half-life calculation.