Commit 579e39b4 authored by webchick's avatar webchick

#314349 by mfb, Damien Tournoud, catch, scor, cha0s: Fixed random failures...

#314349 by mfb, Damien Tournoud, catch, scor, cha0s: Fixed random failures from comment paging tests.
parent 2f097f48
......@@ -351,6 +351,14 @@ function comment_update_7013(&$sandbox) {
}
}
/**
* Optimize index for comment_num_new() and comment_new_page_count().
*/
function comment_update_7014() {
db_drop_index('comment', 'comment_num_new');
db_add_index('comment', 'comment_num_new', array('nid', 'status', 'created', 'cid', 'thread'));
}
/**
* @} End of "defgroup updates-6.x-to-7.x"
* The next series of updates should start at 8000.
......@@ -454,7 +462,7 @@ function comment_schema() {
),
'indexes' => array(
'comment_status_pid' => array('pid', 'status'),
'comment_num_new' => array('nid', 'changed', 'status'),
'comment_num_new' => array('nid', 'status', 'created', 'cid', 'thread'),
'comment_uid' => array('uid'),
'comment_nid_language' => array('nid', 'language'),
),
......
......@@ -523,7 +523,8 @@ function comment_new_page_count($num_comments, $new_replies, $node) {
->fields('comment', array('thread'))
->condition('nid', $node->nid)
->condition('status', COMMENT_PUBLISHED)
->orderBy('changed', 'DESC')
->orderBy('created', 'DESC')
->orderBy('cid', 'DESC')
->range(0, $new_replies);
// 2. Find the first thread.
......@@ -1643,7 +1644,7 @@ function comment_num_new($nid, $timestamp = 0) {
$timestamp = ($timestamp > NODE_NEW_LIMIT ? $timestamp : NODE_NEW_LIMIT);
// Use the timestamp to retrieve the number of new comments.
return db_query('SELECT COUNT(cid) FROM {comment} WHERE nid = :nid AND changed > :timestamp AND status = :status', array(
return db_query('SELECT COUNT(cid) FROM {comment} WHERE nid = :nid AND created > :timestamp AND status = :status', array(
':nid' => $nid,
':timestamp' => $timestamp,
':status' => COMMENT_PUBLISHED,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment