Index: modules/node/node.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.module,v
retrieving revision 1.776.2.33
diff -u -r1.776.2.33 node.module
--- modules/node/node.module	14 Jan 2009 23:32:14 -0000	1.776.2.33
+++ modules/node/node.module	15 Apr 2009 23:40:00 -0000
@@ -2567,30 +2567,31 @@
   variable_set('node_cron_comments_scale', 1.0 / max(1, db_result(db_query('SELECT MAX(comment_count) FROM {node_comment_statistics}'))));
   variable_set('node_cron_views_scale', 1.0 / max(1, db_result(db_query('SELECT MAX(totalcount) FROM {node_counter}'))));
 
-  $result = db_query_range('SELECT GREATEST(IF(c.last_comment_timestamp IS NULL, 0, c.last_comment_timestamp), n.changed) as last_change, n.nid FROM {node} n LEFT JOIN {node_comment_statistics} c ON n.nid = c.nid WHERE n.status = 1 AND ((GREATEST(n.changed, c.last_comment_timestamp) = %d AND n.nid > %d) OR (n.changed > %d OR c.last_comment_timestamp > %d)) ORDER BY GREATEST(n.changed, c.last_comment_timestamp) ASC, n.nid ASC', $last, $last_nid, $last, $last, $last, 0, $limit);
+  $result = db_query_range('SELECT GREATEST(IF(c.last_comment_timestamp IS NULL, 0, c.last_comment_timestamp), n.changed) as last_change, n.nid FROM {node} n LEFT JOIN {node_comment_statistics} c ON n.nid = c.nid WHERE n.status = 1 AND ((GREATEST(n.changed, c.last_comment_timestamp) = %d AND n.nid > %d) OR (n.changed > %d OR c.last_comment_timestamp > %d)) ORDER BY last_change ASC, n.nid ASC', $last, $last_nid, $last, $last, $last, 0, $limit);
 
   while ($node = db_fetch_object($result)) {
     $last_change = $node->last_change;
     $last_nid = $node->nid;
-    $node = node_load($node->nid);
 
-    // Build the node body.
-    $node = node_build_content($node, FALSE, FALSE);
-    $node->body = drupal_render($node->content);
-
-    // Allow modules to modify the fully-built node.
-    node_invoke_nodeapi($node, 'alter');
-
-    $text = '<h1>'. check_plain($node->title) .'</h1>'. $node->body;
+    if($node = node_load($node->nid)){
+      // Build the node body.
+      $node = node_build_content($node, FALSE, FALSE);
+      $node->body = drupal_render($node->content);
+
+      // Allow modules to modify the fully-built node.
+      node_invoke_nodeapi($node, 'alter');
+
+      $text = '<h1>'. check_plain($node->title) .'</h1>'. $node->body;
+
+      // Fetch extra data normally not visible
+      $extra = node_invoke_nodeapi($node, 'update index');
+      foreach ($extra as $t) {
+        $text .= $t;
+      }
 
-    // Fetch extra data normally not visible
-    $extra = node_invoke_nodeapi($node, 'update index');
-    foreach ($extra as $t) {
-      $text .= $t;
+      // Update index
+      search_index($node->nid, 'node', $text);
     }
-
-    // Update index
-    search_index($node->nid, 'node', $text);
   }
 }
 
