From b3e3f8ae373c47fae44156d86fc481fcb196c17b Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Thu, 4 Nov 2004 21:05:06 +0000 Subject: - Updated forum_block() to pass comment_count's to node_title_list(). This eliminates up to 10 SQL queries (sometimes less) for each non-cached page view on drupal.org. Derived from ccourtne's patch. --- modules/forum.module | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'modules/forum.module') diff --git a/modules/forum.module b/modules/forum.module index b96d5da4b..e116cb34c 100644 --- a/modules/forum.module +++ b/modules/forum.module @@ -127,9 +127,9 @@ function forum_block($op = 'list', $delta = 0, $edit = array()) { case 'view': if (user_access('access content')) { - $content = node_title_list(db_query_range("SELECT n.nid, n.title, l.last_comment_timestamp FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid ". node_access_join_sql() ." WHERE n.status = 1 AND n.type='forum' AND ". node_access_where_sql() ." ORDER BY l.last_comment_timestamp DESC", 0, variable_get('forum_block_num', '5')), t('Active forum topics:')); + $content = node_title_list(db_query_range("SELECT n.nid, n.title, l.last_comment_timestamp, l.comment_count FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid ". node_access_join_sql() ." WHERE n.status = 1 AND n.type='forum' AND ". node_access_where_sql() ." ORDER BY l.last_comment_timestamp DESC", 0, variable_get('forum_block_num', '5')), t('Active forum topics:')); - $content .= node_title_list(db_query_range("SELECT n.nid, n.title FROM {node} n ". node_access_join_sql() ." WHERE n.type = 'forum' AND n.status = 1 AND ". node_access_where_sql() ." ORDER BY n.nid DESC", 0, variable_get('forum_block_num', '5')), t('New forum topics:')); + $content .= node_title_list(db_query_range("SELECT n.nid, n.title, l.comment_count FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid ". node_access_join_sql() ." WHERE n.type = 'forum' AND n.status = 1 AND ". node_access_where_sql() ." ORDER BY n.nid DESC", 0, variable_get('forum_block_num', '5')), t('New forum topics:')); if ($content) { $content .= ''; -- cgit v1.2.3