Index: apachesolr.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/apachesolr/apachesolr.module,v
retrieving revision 1.1.2.12.2.140
diff -u -p -r1.1.2.12.2.140 apachesolr.module
--- apachesolr.module	7 May 2009 16:05:55 -0000	1.1.2.12.2.140
+++ apachesolr.module	13 May 2009 14:33:20 -0000
@@ -274,11 +274,16 @@ function _apachesolr_exclude_types($name
 }
 
 /**
- * Returns a resource from a query based on an indexing namespace.
+ * Returns an array of rows from a query based on an indexing namespace.
  */
 function apachesolr_get_nodes_to_index($namespace, $limit) {
+  $rows = array();
   list($excluded_types, $args, $join_sql, $exclude_sql) = _apachesolr_exclude_types($namespace);
-  return  db_query_range("SELECT asn.nid, asn.changed FROM {apachesolr_search_node} asn ". $join_sql ."WHERE (asn.changed > %d OR (asn.changed = %d AND asn.nid > %d)) AND asn.status = 1 ". $exclude_sql ."ORDER BY asn.changed ASC, asn.nid ASC", $args, 0, $limit);
+  $result = db_query_range("SELECT asn.nid, asn.changed FROM {apachesolr_search_node} asn ". $join_sql ."WHERE (asn.changed > %d OR (asn.changed = %d AND asn.nid > %d)) AND asn.status = 1 ". $exclude_sql ."ORDER BY asn.changed ASC, asn.nid ASC", $args, 0, $limit);
+  while($row = db_fetch_object($result)) {
+    $rows[] = $row;
+  }
+  return $rows;
 }
 
 /**
@@ -288,7 +293,12 @@ function apachesolr_get_nodes_to_index($
  * the timestamp and nid returned.
  * Returns FALSE if no nodes were indexed (none found or error).
  */
-function apachesolr_index_nodes($result, $namespace = '', $callback = 'apachesolr_add_node_document') {
+function apachesolr_index_nodes($rows, $namespace = '', $callback = 'apachesolr_add_node_document') {
+  if (!$rows) {
+    // Nothing to do.
+    return FALSE;
+  }
+
   try {
     // Get the $solr object
     $solr = apachesolr_get_solr();
@@ -306,7 +316,7 @@ function apachesolr_index_nodes($result,
   $old_position = apachesolr_get_last_index($namespace);
   $position = $old_position;
 
-  while ($row = db_fetch_object($result)) {
+  foreach ($rows as $row) {
     // Variables to track the last item changed.
     $position['last_change'] = $row->changed;
     $position['last_nid'] = $row->nid;
Index: apachesolr_search.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/apachesolr/apachesolr_search.module,v
retrieving revision 1.1.2.6.2.90
diff -u -p -r1.1.2.6.2.90 apachesolr_search.module
--- apachesolr_search.module	6 May 2009 01:15:35 -0000	1.1.2.6.2.90
+++ apachesolr_search.module	13 May 2009 14:33:20 -0000
@@ -57,8 +57,8 @@ function apachesolr_search_menu() {
  */
 function apachesolr_search_update_index() {
   $cron_limit = variable_get('apachesolr_cron_limit', 50);
-  $result = apachesolr_get_nodes_to_index('apachesolr_search', $cron_limit);
-  apachesolr_index_nodes($result, 'apachesolr_search');
+  $rows = apachesolr_get_nodes_to_index('apachesolr_search', $cron_limit);
+  apachesolr_index_nodes($rows, 'apachesolr_search');
 }
 
 /**
