? .svn
? SolrPhpClient
? contrib/.svn
? contrib/apachesolr_image/.svn
? contrib/apachesolr_nodeaccess/.svn
? contrib/apachesolr_nodeaccess/tests/.svn
? contrib/apachesolr_og/.svn
? tests/.svn
Index: apachesolr.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/apachesolr/apachesolr.admin.inc,v
retrieving revision 1.1.2.28.2.2
diff -u -p -r1.1.2.28.2.2 apachesolr.admin.inc
--- apachesolr.admin.inc	16 Jul 2009 13:14:51 -0000	1.1.2.28.2.2
+++ apachesolr.admin.inc	21 Jul 2009 10:02:52 -0000
@@ -354,7 +354,7 @@ function apachesolr_clear_index_confirm(
  */
 function apachesolr_clear_index_confirm_submit($form, &$form_state) {
   $form_state['redirect'] = 'admin/settings/apachesolr/index';
-  apachesolr_clear_last_index();
+  apachesolr_rebuild_index_table();
 }
 
 
@@ -411,8 +411,7 @@ function apachesolr_delete_index() {
   $solr->deleteByQuery($query);
   $solr->commit();
   // Rebuild our node-tracking table.
-  module_load_include('install', 'apachesolr');
-  apachesolr_enable();
+  apachesolr_rebuild_index_table();
   apachesolr_index_updated(time());
 }
 
Index: apachesolr.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/apachesolr/apachesolr.install,v
retrieving revision 1.1.4.18.2.1
diff -u -p -r1.1.4.18.2.1 apachesolr.install
--- apachesolr.install	16 Jul 2009 09:28:16 -0000	1.1.4.18.2.1
+++ apachesolr.install	21 Jul 2009 10:02:52 -0000
@@ -23,17 +23,8 @@ function apachesolr_install() {
  * Implementation of hook_enable().
  */
 function apachesolr_enable() {
-  // Make sure we don't have stale data.
-  apachesolr_clear_last_index();
-  db_query("DELETE FROM {apachesolr_search_node}");
-  // Populate table
-  db_query("INSERT INTO {apachesolr_search_node} (nid, status, changed)
-            SELECT n.nid, n.status, GREATEST(n.created, n.changed, c.last_comment_timestamp) AS changed
-            FROM {node} n
-            INNER JOIN {node_comment_statistics} c ON n.nid = c.nid");
-   // Make sure no nodes end up with a timestamp that's in the future.
-   $time = time();
-   db_query("UPDATE {apachesolr_search_node} SET changed = %d WHERE changed > %d", $time, $time);
+  // Completely build the index table.
+  apachesolr_rebuild_index_table();
 }
 
 /**
Index: apachesolr.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/apachesolr/apachesolr.module,v
retrieving revision 1.1.2.12.2.155.2.1
diff -u -p -r1.1.2.12.2.155.2.1 apachesolr.module
--- apachesolr.module	16 Jul 2009 13:14:51 -0000	1.1.2.12.2.155.2.1
+++ apachesolr.module	21 Jul 2009 10:02:53 -0000
@@ -238,7 +238,6 @@ function apachesolr_node_type($op, $info
  */
 function apachesolr_index_status($namespace) {
   list($excluded_types, $args, $join_sql, $exclude_sql) = _apachesolr_exclude_types($namespace);
-
   $total = db_result(db_query("SELECT COUNT(asn.nid) FROM {apachesolr_search_node} asn ". $join_sql ."WHERE asn.status = 1 " . $exclude_sql, $excluded_types));
   $remaining = db_result(db_query("SELECT COUNT(asn.nid) 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, $args));
   return array('remaining' => $remaining, 'total' => $total);
@@ -266,6 +265,24 @@ function apachesolr_clear_last_index($na
   }
 }
 
+/**
+ * Truncate and rebuild the apachesolr_search_node table, reset the apachesolr_index_last variable.
+ * This is the most complete way to force reindexing, or to build the indexing table for the
+ * first time.
+ */
+function apachesolr_rebuild_index_table() {
+  db_query("DELETE FROM {apachesolr_search_node}");
+  // Populate table
+  db_query("INSERT INTO {apachesolr_search_node} (nid, status, changed)
+            SELECT n.nid, n.status, GREATEST(n.created, n.changed, c.last_comment_timestamp) AS changed
+            FROM {node} n
+            LEFT JOIN {node_comment_statistics} c ON n.nid = c.nid");
+   // Make sure no nodes end up with a timestamp that's in the future.
+   $time = time();
+   db_query("UPDATE {apachesolr_search_node} SET changed = %d WHERE changed > %d", $time, $time);
+   apachesolr_clear_last_index();
+}
+
 function _apachesolr_exclude_types($namespace) {
   extract(apachesolr_get_last_index($namespace));
   $excluded_types = module_invoke_all('apachesolr_types_exclude', $namespace);
