diff -urpN drupal-6.x-dev-200708130010/includes/menu.inc drupal-6.x-dev-rmnumrow-0.9.2/includes/menu.inc
--- drupal-6.x-dev-200708130010/includes/menu.inc	2007-08-12 23:55:35.000000000 +0800
+++ drupal-6.x-dev-rmnumrow-0.9.2/includes/menu.inc	2007-08-13 00:20:21.000000000 +0800
@@ -720,11 +720,13 @@ function menu_tree_page_data($menu_name 
             // their children to the list as well.
             do {
               $result = db_query("SELECT mlid FROM {menu_links} WHERE menu_name = '%s' AND expanded = 1 AND has_children = 1 AND plid IN (". $placeholders .') AND mlid NOT IN ('. $placeholders .')', array_merge(array($menu_name), $args, $args));
+              $num_rows = FALSE;
               while ($item = db_fetch_array($result)) {
                 $args[] = $item['mlid'];
+                $num_rows = TRUE;
               }
               $placeholders = implode(', ', array_fill(0, count($args), '%d'));
-            } while ($item);
+            } while ($num_rows);
           }
           array_unshift($args, $menu_name);
         }
diff -urpN drupal-6.x-dev-200708130010/modules/aggregator/aggregator.module drupal-6.x-dev-rmnumrow-0.9.2/modules/aggregator/aggregator.module
--- drupal-6.x-dev-200708130010/modules/aggregator/aggregator.module	2007-08-12 23:55:35.000000000 +0800
+++ drupal-6.x-dev-rmnumrow-0.9.2/modules/aggregator/aggregator.module	2007-08-13 00:20:58.000000000 +0800
@@ -964,10 +964,12 @@ function aggregator_parse_feed(&$data, $
   $result = db_query('SELECT iid FROM {aggregator_item} WHERE fid = %d AND timestamp < %d', $feed['fid'], $age);
 
   $items = array();
+  $num_rows = FALSE;
   while ($item = db_fetch_object($result)) {
     $items[] = $item->iid;
+    $num_rows = TRUE;
   }
-  if ($item) {
+  if ($num_rows) {
     db_query('DELETE FROM {aggregator_category_item} WHERE iid IN ('. implode(', ', $items) .')');
     db_query('DELETE FROM {aggregator_item} WHERE fid = %d AND timestamp < %d', $feed['fid'], $age);
   }
diff -urpN drupal-6.x-dev-200708130010/modules/comment/comment.module drupal-6.x-dev-rmnumrow-0.9.2/modules/comment/comment.module
--- drupal-6.x-dev-200708130010/modules/comment/comment.module	2007-08-12 23:55:35.000000000 +0800
+++ drupal-6.x-dev-rmnumrow-0.9.2/modules/comment/comment.module	2007-08-13 00:21:40.000000000 +0800
@@ -1019,6 +1019,7 @@ function comment_render($node, $cid = 0)
 
       $divs = 0;
       $last_depth = 0;
+      $num_rows = FALSE;
       $comments = '';
       drupal_add_css(drupal_get_path('module', 'comment') .'/comment.css');
       while ($comment = db_fetch_object($result)) {
@@ -1053,9 +1054,11 @@ function comment_render($node, $cid = 0)
         else if ($mode == COMMENT_MODE_THREADED_EXPANDED) {
           $comments .= theme('comment_thread_expanded', $comment, $node);
         }
+
+        $num_rows = TRUE;
       }
 
-      if ($comment && (variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_ABOVE || variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_ABOVE_BELOW)) {
+      if ($num_rows && (variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_ABOVE || variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_ABOVE_BELOW)) {
         $output .= drupal_get_form('comment_controls', $mode, $order, $comments_per_page);
       }
       $output .= $comments;
@@ -1065,7 +1068,7 @@ function comment_render($node, $cid = 0)
       }
       $output .= theme('pager', NULL, $comments_per_page, 0);
 
-      if ($comment && (variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_BELOW || variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_ABOVE_BELOW)) {
+      if ($num_rows && (variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_BELOW || variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_ABOVE_BELOW)) {
         $output .= drupal_get_form('comment_controls', $mode, $order, $comments_per_page);
       }
     }
diff -urpN drupal-6.x-dev-200708130010/modules/node/node.module drupal-6.x-dev-rmnumrow-0.9.2/modules/node/node.module
--- drupal-6.x-dev-200708130010/modules/node/node.module	2007-08-12 23:55:36.000000000 +0800
+++ drupal-6.x-dev-rmnumrow-0.9.2/modules/node/node.module	2007-08-13 00:22:22.000000000 +0800
@@ -119,11 +119,13 @@ function node_cron() {
  */
 function node_title_list($result, $title = NULL) {
   $items = array();
+  $num_rows = FALSE;
   while ($node = db_fetch_object($result)) {
     $items[] = l($node->title, 'node/'. $node->nid, !empty($node->comment_count) ? array('title' => format_plural($node->comment_count, '1 comment', '@count comments')) : array());
+    $num_rows = TRUE;
   }
 
-  return $node ? theme('node_list', $items, $title) : FALSE;
+  return $num_rows ? theme('node_list', $items, $title) : FALSE;
 }
 
 /**
@@ -2557,11 +2559,13 @@ function node_page_default() {
   $result = pager_query(db_rewrite_sql('SELECT n.nid, n.sticky, n.created FROM {node} n WHERE n.promote = 1 AND n.status = 1 ORDER BY n.sticky DESC, n.created DESC'), variable_get('default_nodes_main', 10));
 
   $output = '';
+  $num_rows = FALSE;
   while ($node = db_fetch_object($result)) {
     $output .= node_view(node_load($node->nid), 1);
+    $num_rows = TRUE;
   }
 
-  if ($node) {
+  if ($num_rows) {
     $feed_url = url('rss.xml', array('absolute' => TRUE));
     drupal_add_feed($feed_url, variable_get('site_name', 'Drupal') .' '. t('RSS'));
     $output .= theme('pager', NULL, variable_get('default_nodes_main', 10));
diff -urpN drupal-6.x-dev-200708130010/modules/system/system.install drupal-6.x-dev-rmnumrow-0.9.2/modules/system/system.install
--- drupal-6.x-dev-200708130010/modules/system/system.install	2007-08-12 23:55:36.000000000 +0800
+++ drupal-6.x-dev-rmnumrow-0.9.2/modules/system/system.install	2007-08-13 00:30:59.000000000 +0800
@@ -2169,6 +2169,8 @@ function system_update_179() {
     $limit = 20;
     $args = array_merge(array($_SESSION['system_update_179_uid'], $_SESSION['system_update_179_fid'], $_SESSION['system_update_179_uid']), $_SESSION['system_update_179_fields']);
     $result = db_query_range("SELECT fid, uid, value FROM {profile_values} WHERE ((uid = %d AND fid > %d) OR uid > %d) AND fid IN ". $_SESSION['system_update_179_field_string'] .' ORDER BY uid ASC, fid ASC', $args, 0, $limit);
+
+    $num_rows = FALSE;
     while ($field = db_fetch_object($result)) {
       $_SESSION['system_update_179_uid'] = $field->uid;
       $_SESSION['system_update_179_fid'] = $field->fid;
@@ -2176,11 +2178,11 @@ function system_update_179() {
       if ($field->value !== FALSE) {
         db_query("UPDATE {profile_values} SET value = '%s' WHERE uid = %d AND fid = %d", $field->value, $field->uid, $field->fid);
       }
-
+      $num_rows = TRUE;
     }
 
     // Done?
-    if (!$field) {
+    if (!$num_rows) {
       unset($_SESSION['system_update_179_uid']);
       unset($_SESSION['system_update_179_fid']);
       unset($_SESSION['system_update_179_max']);
diff -urpN drupal-6.x-dev-200708130010/modules/taxonomy/taxonomy.module drupal-6.x-dev-rmnumrow-0.9.2/modules/taxonomy/taxonomy.module
--- drupal-6.x-dev-200708130010/modules/taxonomy/taxonomy.module	2007-08-12 23:55:36.000000000 +0800
+++ drupal-6.x-dev-rmnumrow-0.9.2/modules/taxonomy/taxonomy.module	2007-08-13 00:19:29.000000000 +0800
@@ -983,10 +983,12 @@ function taxonomy_select_nodes($tids = a
 */
 function taxonomy_render_nodes($result) {
   $output = '';
+  $num_rows = FALSE;
   while ($node = db_fetch_object($result)) {
     $output .= node_view(node_load($node->nid), 1);
+    $num_rows = TRUE;
   }
-  if ($node) {
+  if ($num_rows) {
     $output .= theme('pager', NULL, variable_get('default_nodes_main', 10), 0);
   }
   else {
diff -urpN drupal-6.x-dev-200708130010/modules/user/user.module drupal-6.x-dev-rmnumrow-0.9.2/modules/user/user.module
--- drupal-6.x-dev-200708130010/modules/user/user.module	2007-08-12 23:55:36.000000000 +0800
+++ drupal-6.x-dev-rmnumrow-0.9.2/modules/user/user.module	2007-08-13 00:18:34.000000000 +0800
@@ -1096,10 +1096,12 @@ function user_current_to_arg($arg) {
 function user_get_authmaps($authname = NULL) {
   $result = db_query("SELECT authname, module FROM {authmap} WHERE authname = '%s'", $authname);
   $authmaps = array();
+  $num_rows = FALSE;
   while ($authmap = db_fetch_object($result)) {
     $authmaps[$authmap->module] = $authmap->authname;
+    $num_rows = TRUE;
   }
-  return count($authmaps) ? $authmaps : 0;
+  return $num_rows ? $authmaps : 0;
 }
 
 function user_set_authmaps($account, $authmaps) {
