diff options
author | Dries Buytaert <dries@buytaert.net> | 2008-06-18 16:06:42 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2008-06-18 16:06:42 +0000 |
commit | 61cc35f2b0820733ff40a9775da45fa93a078584 (patch) | |
tree | e957ab408ab630f278992c6d5113af49e4b9d7ef /modules/comment/comment.module | |
parent | 6e2358b23208ef7e2119d95b0cea1537d9a863c8 (diff) | |
download | brdo-61cc35f2b0820733ff40a9775da45fa93a078584.tar.gz brdo-61cc35f2b0820733ff40a9775da45fa93a078584.tar.bz2 |
- Patch #255918 by R.Muilwijk: performance improvement: comment_link querying for already retrieved data.
Diffstat (limited to 'modules/comment/comment.module')
-rw-r--r-- | modules/comment/comment.module | 25 |
1 files changed, 3 insertions, 22 deletions
diff --git a/modules/comment/comment.module b/modules/comment/comment.module index ce84a6e34..7e261b52a 100644 --- a/modules/comment/comment.module +++ b/modules/comment/comment.module @@ -418,10 +418,9 @@ function comment_link($type, $node = NULL, $teaser = FALSE) { if ($teaser) { // Main page: display the number of comments that have been posted. if (user_access('access comments')) { - $all = comment_num_all($node->nid); - if ($all) { + if ($node->comment_count) { $links['comment_comments'] = array( - 'title' => format_plural($all, '1 comment', '@count comments'), + 'title' => format_plural($node->comment_count, '1 comment', '@count comments'), 'href' => "node/$node->nid", 'attributes' => array('title' => t('Jump to the first comment of this posting.')), 'fragment' => 'comments' @@ -432,7 +431,7 @@ function comment_link($type, $node = NULL, $teaser = FALSE) { $links['comment_new_comments'] = array( 'title' => format_plural($new, '1 new comment', '@count new comments'), 'href' => "node/$node->nid", - 'query' => comment_new_page_count($all, $new, $node), + 'query' => comment_new_page_count($node->comment_count, $new, $node), 'attributes' => array('title' => t('Jump to the first new comment of this posting.')), 'fragment' => 'new' ); @@ -1086,24 +1085,6 @@ function comment_load($cid) { } /** - * Get comment count for a node. - * - * @param $nid - * The node id. - * @return - * The comment count. - */ -function comment_num_all($nid) { - static $cache; - - if (!isset($cache[$nid])) { - $cache[$nid] = db_result(db_query('SELECT comment_count FROM {node_comment_statistics} WHERE nid = %d', $nid)); - } - - return $cache[$nid]; -} - -/** * Get replies count for a comment. * * @param $pid |