diff --git a/modules/comment/comment.install b/modules/comment/comment.install index 44b323fc1f3c304566d4b41030a6cb000ebca4b4..1dd67f4dddf5f421d4caec27b12cf56b2d8812c8 100644 --- a/modules/comment/comment.install +++ b/modules/comment/comment.install @@ -179,6 +179,7 @@ function comment_schema() { 'comment_num_new' => array('nid', 'status', 'created', 'cid', 'thread'), 'comment_uid' => array('uid'), 'comment_nid_language' => array('nid', 'language'), + 'comment_created' => array('created'), ), 'primary key' => array('cid'), 'foreign keys' => array( diff --git a/modules/comment/comment.module b/modules/comment/comment.module index e69d07fc5f9e42849b5f3c0f01240089cad0f223..ec57dd41f8ad49bcb64d836e3ec07c07718ca567 100644 --- a/modules/comment/comment.module +++ b/modules/comment/comment.module @@ -494,6 +494,7 @@ function comment_permalink($cid) { * * @param integer $number * (optional) The maximum number of comments to find. Defaults to 10. + * * @return * An array of comment objects or an empty array if there are no recent * comments visible to the current user. @@ -501,15 +502,12 @@ function comment_permalink($cid) { function comment_get_recent($number = 10) { $query = db_select('comment', 'c'); $query->innerJoin('node', 'n', 'n.nid = c.nid'); - $query->innerJoin('node_comment_statistics', 'ncs', 'ncs.nid = c.nid'); $query->addTag('node_access'); $comments = $query ->fields('c') - ->condition('ncs.comment_count', 0, '>') ->condition('c.status', COMMENT_PUBLISHED) ->condition('n.status', NODE_PUBLISHED) - ->orderBy('ncs.last_comment_timestamp', 'DESC') - ->orderBy('c.cid', 'DESC') + ->orderBy('c.created', 'DESC') ->range(0, $number) ->execute() ->fetchAll();