? flat_comments_reply_count.patch
? htaccess.patch
? sites/default/files
? sites/default/settings.php
Index: modules/comment/comment.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v
retrieving revision 1.686
diff -u -p -r1.686 comment.module
--- modules/comment/comment.module	23 Jan 2009 14:23:27 -0000	1.686
+++ modules/comment/comment.module	25 Jan 2009 17:34:31 -0000
@@ -1225,14 +1225,19 @@ function comment_load($cid) {
 function comment_num_replies($pid) {
   static $cache;
 
-  if (!isset($cache[$pid])) {
-    $cache[$pid] = db_query('SELECT COUNT(cid) FROM {comment} WHERE pid = :pid AND status = :status', array(
-      ':pid' => $pid,
-      ':status' => COMMENT_PUBLISHED))
-      ->fetchField();
+  // Only calculate when threaded comments are enabled
+  $mode = variable_get('comment_default_mode', COMMENT_MODE_THREADED_EXPANDED);
+  if (COMMENT_MODE_THREADED_EXPANDED == $mode || COMMENT_MODE_THREADED_COLLAPSED == $mode) {
+    if (!isset($cache[$pid])) {
+      $cache[$pid] = db_query('SELECT COUNT(cid) FROM {comment} WHERE pid = :pid AND status = :status', array(
+        ':pid' => $pid,
+        ':status' => COMMENT_PUBLISHED))
+        ->fetchField();
+    }
+    return $cache[$pid];
   }
-
-  return $cache[$pid];
+  // Otherwise the number of replies to this comment will be 0
+  else return 0;
 }
 
 /**
