Index: modules/comment/comment.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v
retrieving revision 1.775
diff -u -p -r1.775 comment.module
--- modules/comment/comment.module	29 Sep 2009 15:31:14 -0000	1.775
+++ modules/comment/comment.module	8 Oct 2009 23:46:10 -0000
@@ -586,7 +586,9 @@ function comment_node_page_additions($no
   // Unpublished comments are not included in $node->comment_count, so show
   // comments unconditionally if the user is an administrator.
   if ($node->comment_count || user_access('administer comments')) {
-    if ($cids = comment_get_thread($node)) {
+    $mode = _comment_get_display_setting('mode', $node);
+    $comments_per_page = _comment_get_display_setting('comments_per_page', $node);
+    if ($cids = comment_get_thread($node, $mode, $comments_per_page)) {
       $comments = comment_load_multiple($cids);
       comment_prepare_thread($comments);
       $build = comment_build_multiple($comments, $node);
@@ -615,10 +617,14 @@ function comment_node_page_additions($no
 }
 
 /**
- * Retrieve comment(s) for a thread.
+ * Retrieve comments for a thread.
  *
  * @param $node
  *   The node whose comment(s) needs rendering.
+ * @param $mode
+ *   The comment display mode; COMMENT_MODE_FLAT or COMMENT_MODE_THREADED.
+ * @param $comments_per_page
+ *   The amount of comments to display per page.
  *
  * To display threaded comments in the correct order we keep a 'thread' field
  * and order by that value. This field keeps this data in
@@ -674,10 +680,7 @@ function comment_node_page_additions($no
  * spoil the reverse ordering, "ORDER BY thread ASC" -- here, we do not need
  * to consider the trailing "/" so we use a substring only.
  */
- function comment_get_thread($node) {
-  $mode = _comment_get_display_setting('mode', $node);
-  $comments_per_page = _comment_get_display_setting('comments_per_page', $node);
-
+function comment_get_thread($node, $mode, $comments_per_page) {
   $query = db_select('comment', 'c')->extend('PagerDefault');
   $query->addField('c', 'cid');
   $query
