? contrib/.svn
? contrib/apachesolr_attachments/.svn
? contrib/apachesolr_image/.svn
? contrib/apachesolr_lang/.svn
? contrib/apachesolr_mlt/.svn
? contrib/apachesolr_multisitesearch/.svn
? contrib/apachesolr_nodeaccess/.svn
? contrib/apachesolr_nodeaccess/tests/.svn
Index: apachesolr.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/apachesolr/apachesolr.module,v
retrieving revision 1.1.2.12.2.64
diff -u -p -r1.1.2.12.2.64 apachesolr.module
--- apachesolr.module	2 Dec 2008 01:53:17 -0000	1.1.2.12.2.64
+++ apachesolr.module	2 Dec 2008 21:43:13 -0000
@@ -150,8 +150,10 @@ function apachesolr_requirements($phase)
   }
 }
 
+/**
+ * Gets information about the fields already in solr index.
+ */
 function apachesolr_index_page() {
-  // Gets information about the fields already in solr index.
   try {
     $solr = apachesolr_get_solr();
     $data = $solr->getLuke(1);
@@ -229,6 +231,7 @@ function apachesolr_delete_index_form_su
       drupal_alter('apachesolr_delete_index', $query);
       $solr->deleteByQuery($query);
       $solr->commit();
+      apachesolr_clear_last_index();
       // This form can't be seen by anyone without 'administer site configuration'
       // permission, so no need to check perms before displaying a run-cron link.
       drupal_set_message(t('The Solr content index has been erased. You must now !run_cron until your entire site has been re-indexed.', array('!run_cron' => l(t('run cron'), 'admin/reports/status/run-cron', array('query' => array('destination' => 'admin/settings/apachesolr/index'))))));
@@ -255,7 +258,6 @@ function apachesolr_document_id($id, $ty
   return apachesolr_site_hash() . "/$type/" . $id;
 }
 
-
 /**
  * Implementation of hook_user().
  *
@@ -316,26 +318,50 @@ function apachesolr_node_type($op, $info
 /**
  * Helper function for modules implmenting hook_search's 'status' op.
  */
-function apachesolr_index_status($last_change, $last_nid) {
+function apachesolr_index_status($namespace) {
+  extract(apachesolr_get_last_index($namespace));
   $total = db_result(db_query('SELECT COUNT(*) FROM {node} WHERE status = 1'));
   $remaining = db_result(db_query('SELECT COUNT(*) FROM {apachesolr_search_node} WHERE (changed > %d OR (changed = %d AND nid > %d)) AND status = 1', $last_change, $last_change, $last_nid));
   return array('remaining' => $remaining, 'total' => $total);
 }
 
 /**
- * Returns a resource from a query for nid and changed values.
+ * Returns last changed and last nid for an indexing namespace.
+ */
+function apachesolr_get_last_index($namespace) {
+  $stored = variable_get('apachesolr_index_last', array());
+  return isset($stored[$namespace]) ? $stored[$namespace] : array('last_change' => 0, 'last_nid' => 0);
+}
+
+/**
+ * Clear a specific namespace's last changed and nid, or clear all.
  */
-function apachesolr_get_nodes_to_index($last_change, $last_nid, $limit) {
+function apachesolr_clear_last_index($namespace = '') {
+  if ($namespace) {
+    $stored = variable_get('apachesolr_index_last', array());
+    unset($stored[$namespace]);
+    variable_set('apachesolr_index_last', $stored);
+  }
+  else {
+    variable_del('apachesolr_index_last');
+  }
+}
+/**
+ * Returns a resource from a query based on an indexing namespace.
+ */
+function apachesolr_get_nodes_to_index($namespace, $limit) {
+  extract(apachesolr_get_last_index($namespace));
   return  db_query_range("SELECT nid, changed FROM {apachesolr_search_node} WHERE (changed > %d OR (changed = %d AND nid > %d)) AND status = 1 ORDER BY changed ASC, nid ASC", $last_change, $last_change, $last_nid, 0, $limit);
 }
 
 /**
  * Function to handle the indexing of nodes.
  *
- * The calling function must track/store the timestamp and nid returned.
+ * The calling function must supply a name space or track/store
+ * the timestamp and nid returned.
  * Returns FALSE if no nodes were indexed (none found or error).
  */
-function apachesolr_index_nodes($result, $callback = 'apachesolr_add_node_document') {
+function apachesolr_index_nodes($result, $namespace = '', $callback = 'apachesolr_add_node_document') {
   try {
     // Get the $solr object
     $solr = apachesolr_get_solr();
@@ -369,7 +395,13 @@ function apachesolr_index_nodes($result,
       }
       $solr->commit();
       $solr->optimize(FALSE, FALSE);
-      return array('last_change' => $solr_last_change, 'last_nid' => $solr_last_id);
+      $last = array('last_change' => $solr_last_change, 'last_nid' => $solr_last_id);
+      if ($namespace) {
+        $stored = variable_get('apachesolr_index_last', array());
+        $stored[$namespace] = $last;
+        variable_set('apachesolr_index_last', $stored);
+      }
+      return $last;
     }
     catch (Exception $e) {
       watchdog('Apache Solr', $e->getMessage(), NULL, WATCHDOG_ERROR);
Index: apachesolr_search.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/apachesolr/Attic/apachesolr_search.install,v
retrieving revision 1.1.2.1
diff -u -p -r1.1.2.1 apachesolr_search.install
--- apachesolr_search.install	24 Nov 2008 18:29:21 -0000	1.1.2.1
+++ apachesolr_search.install	2 Dec 2008 21:43:13 -0000
@@ -8,9 +8,23 @@
 
 /**
  * Implementation of hook_uninstall().
+ * Update to namespace tracking.
  */
 function apachesolr_search_uninstall() {
+  apachesolr_clear_last_index('apachesolr_search');
+}
+
+/**
+ * Update to namespace tracking.
+ */
+function apachesolr_search_update_6000() {
+  $change = variable_get('apachesolr_search_last_change', 0);
+  $nid = variable_get('apachesolr_search_last_nid', 0);
+  if ($change || $nid) {
+    $stored = variable_get('apachesolr_index_last', array());
+    $stored['apachesolr_search'] = array('last_change' => $change, 'last_nid' => $nid);
+    variable_set('apachesolr_index_last', $stored);
+  }
   variable_del('apachesolr_search_last_change');
   variable_del('apachesolr_search_last_nid');
 }
-
Index: apachesolr_search.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/apachesolr/apachesolr_search.module,v
retrieving revision 1.1.2.6.2.37
diff -u -p -r1.1.2.6.2.37 apachesolr_search.module
--- apachesolr_search.module	2 Dec 2008 01:53:17 -0000	1.1.2.6.2.37
+++ apachesolr_search.module	2 Dec 2008 21:43:13 -0000
@@ -32,31 +32,10 @@ function apachesolr_search_help($section
  * Implementation of hook_update_index().
  */
 function apachesolr_search_update_index() {
-  $last_change = variable_get('apachesolr_search_last_change', 0);
-  $last_nid = variable_get('apachesolr_search_last_nid', 0);
   // TODO - should probably have a separate variable.
   $cron_limit = variable_get('search_cron_limit', 100);
-  $result = apachesolr_get_nodes_to_index($last_change, $last_nid, $cron_limit);
-  $success = apachesolr_index_nodes($result);
-  if ($success) {
-    variable_set('apachesolr_search_last_change', $success['last_change']);
-    variable_set('apachesolr_search_last_nid', $success['last_nid']);
-  }
-}
-
-/**
- * Implementation of hook_form_[form_id]_alter().
- */
-function apachesolr_search_form_apachesolr_delete_index_form_alter(&$form, &$form_state) {
-  $form['#submit'][] = 'apachesolr_search_reindex';
-}
-
-/**
- * Resets indexing variables so all nodes are indexed.
- */
-function apachesolr_search_reindex() {
-  variable_del('apachesolr_search_last_change');
-  variable_del('apachesolr_search_last_nid');
+  $result = apachesolr_get_nodes_to_index('apachesolr_search', $cron_limit);
+  apachesolr_index_nodes($result, 'apachesolr_search');
 }
 
 /**
@@ -69,11 +48,11 @@ function apachesolr_search_search($op = 
       return t('Search');
 
     case 'reset':
-      apachesolr_search_reindex();
+      apachesolr_clear_last_index('apachesolr_search');
       return;
 
     case 'status':
-      return apachesolr_index_status(variable_get('apachesolr_search_last_change', 0), variable_get('apachesolr_search_last_nid', 0));
+      return apachesolr_index_status('apachesolr_search');
 
     case 'search':
       global $pager_total;
Index: contrib/apachesolr_attachments/apachesolr_attachments.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/apachesolr/contrib/apachesolr_attachments/apachesolr_attachments.install,v
retrieving revision 1.1.2.2
diff -u -p -r1.1.2.2 apachesolr_attachments.install
--- contrib/apachesolr_attachments/apachesolr_attachments.install	1 Dec 2008 18:23:46 -0000	1.1.2.2
+++ contrib/apachesolr_attachments/apachesolr_attachments.install	2 Dec 2008 21:43:13 -0000
@@ -16,7 +16,28 @@ function apachesolr_attachments_install(
 function apachesolr_attachments_uninstall() {
   variable_del('apachesolr_attachment_pdf_path');
   variable_del('apachesolr_attachment_txt_path');
-  variable_del('apachesolr_attachment_doc_path');
+  variable_del('apachesolr_attachment_doc_path');  
+}
+
+/**
+ * Implementation of hook_uninstall().
+ * Update to namespace tracking.
+ */
+function apachesolr_attachments_uninstall() {
+  apachesolr_clear_last_index('apachesolr_attachments');
+}
+
+/**
+ * Update to namespace tracking.
+ */
+function apachesolr_attachments_update_6000() {
+  $change = variable_get('apachesolr_attachments_last_change', 0);
+  $nid = variable_get('apachesolr_attachments_last_nid', 0);
+  if ($change || $nid) {
+    $stored = variable_get('apachesolr_index_last', array());
+    $stored['apachesolr_attachments'] = array('last_change' => $change, 'last_nid' => $nid);
+    variable_set('apachesolr_index_last', $stored);
+  }
   variable_del('apachesolr_attachment_last_change');
-  variable_del('apachesolr_attachment_last_nid');  
-} 
+  variable_del('apachesolr_attachment_last_nid');
+}
Index: contrib/apachesolr_attachments/apachesolr_attachments.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/apachesolr/contrib/apachesolr_attachments/apachesolr_attachments.module,v
retrieving revision 1.1.2.5
diff -u -p -r1.1.2.5 apachesolr_attachments.module
--- contrib/apachesolr_attachments/apachesolr_attachments.module	1 Dec 2008 18:24:42 -0000	1.1.2.5
+++ contrib/apachesolr_attachments/apachesolr_attachments.module	2 Dec 2008 21:43:13 -0000
@@ -72,12 +72,11 @@ function apachesolr_attachments_search($
     case 'name':
       return ''; // We dont want a tab
     case 'reset':
-      variable_del('apachesolr_attachment_last_change');
-      variable_del('apachesolr_attachment_last_nid');
+      apachesolr_clear_last_index('apachesolr_attachments');
       return;
     case 'status':
       // TODO: Figure out a way to know how many actual files are left to update.
-      return apachesolr_index_status(variable_get('apachesolr_attachment_last_change', 0), variable_get('apachesolr_attachment_last_nid', 0));
+      return apachesolr_index_status('apachesolr_attachments');
     case 'search':
       return apachesolr_search_search($op, $keys);
   }
@@ -90,18 +89,10 @@ function apachesolr_attachments_search($
  * attachments.
  */
 function apachesolr_attachments_update_index() {
-
-  $last_change = variable_get('apachesolr_attachment_last_change', 0);
-  $last_nid = variable_get('apachesolr_attachment_last_nid', 0);
   // TODO - should probably have a separate variable.
   $cron_limit = variable_get('search_cron_limit', 100);
-  
-  $result = apachesolr_get_nodes_to_index($last_change, $last_nid, $cron_limit);
-  $success = apachesolr_index_nodes($result, 'apachesolr_attachment_add_documents');
-  if ($success) {
-    variable_set('apachesolr_attachment_last_change', $success['last_change']);
-    variable_set('apachesolr_attachment_last_nid',  $success['last_nid']);
-  }
+  $result = apachesolr_get_nodes_to_index('apachesolr_attachments', $cron_limit);
+  apachesolr_index_nodes($result,  'apachesolr_attachments', 'apachesolr_attachments_add_documents');
 }
 
 /**
@@ -109,7 +100,7 @@ function apachesolr_attachments_update_i
  *
  * Adds a document for each indexable file attachment for the given node ID.
  */
-function apachesolr_attachment_add_documents(&$documents, $nid) {
+function apachesolr_attachments_add_documents(&$documents, $nid) {
   $node = node_load($nid, NULL, TRUE);
   if (!empty($node->nid)) {
     
Index: contrib/apachesolr_nodeaccess/apachesolr_nodeaccess.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/apachesolr/contrib/apachesolr_nodeaccess/Attic/apachesolr_nodeaccess.module,v
retrieving revision 1.1.2.1
diff -u -p -r1.1.2.1 apachesolr_nodeaccess.module
--- contrib/apachesolr_nodeaccess/apachesolr_nodeaccess.module	22 Nov 2008 10:28:17 -0000	1.1.2.1
+++ contrib/apachesolr_nodeaccess/apachesolr_nodeaccess.module	2 Dec 2008 21:43:13 -0000
@@ -107,5 +107,5 @@ function apachesolr_nodeaccess_form_alte
 function apachesolr_nodeaccess_rebuild_nodeaccess(&$form, $form_state) {
   drupal_set_message(t('Solr search index will be rebuilt.'));
   node_access_needs_rebuild(TRUE);
-  ApacheSolrUpdate::reset('apachesolr');
+  apachesolr_clear_last_index();
 }
