summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2011-05-14 13:29:17 -0400
committerDries Buytaert <dries@buytaert.net>2011-05-14 13:29:17 -0400
commit2646b43acdd3cf1e11319d8ea5bec01d9eaac2a2 (patch)
treec7d87ed0ffef428bb583de65c10647c3901cb336
parent0b007f5413c990686e648aab3919e8fc94d67de1 (diff)
downloadbrdo-2646b43acdd3cf1e11319d8ea5bec01d9eaac2a2.tar.gz
brdo-2646b43acdd3cf1e11319d8ea5bec01d9eaac2a2.tar.bz2
- Patch #1149912 by grendzy, sun: recent comments block displays old, out-of-order comments.
-rw-r--r--modules/comment/comment.install8
-rw-r--r--modules/comment/comment.module6
2 files changed, 10 insertions, 4 deletions
diff --git a/modules/comment/comment.install b/modules/comment/comment.install
index aac95759c..51bfa7453 100644
--- a/modules/comment/comment.install
+++ b/modules/comment/comment.install
@@ -337,6 +337,13 @@ function comment_update_7006(&$sandbox) {
}
/**
+ * Add an index to the created column.
+ */
+function comment_update_7007() {
+ db_add_index('comment', 'comment_created', array('created'));
+}
+
+/**
* @} End of "addtogroup updates-6.x-to-7.x"
*/
@@ -441,6 +448,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 5526bebe9..836f2fed8 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();