From ecfb959816372ce7507aa45add2ec74ea3872576 Mon Sep 17 00:00:00 2001
From: Neil Drumm <drumm@delocalizedham.com>
Date: Tue, 30 Oct 2012 13:27:05 -0700
Subject: [PATCH] [#1827320] Bypass updates 7000 to 7015 if 6303 has run.

---
 apachesolr.install |   74 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 74 insertions(+)

diff --git a/apachesolr.install b/apachesolr.install
index 26b34c3..770d280 100644
--- a/apachesolr.install
+++ b/apachesolr.install
@@ -279,6 +279,7 @@ function apachesolr_uninstall() {
   variable_del('apachesolr_read_only');
   variable_del('apachesolr_set_nodeapi_messages');
   variable_del('apachesolr_last_optimize');
+  variable_del('apachesolr_update_from_6303');
   // Remove blocks.
   db_delete('block')->condition('module', 'apachesolr')->execute();
 }
@@ -287,6 +288,9 @@ function apachesolr_uninstall() {
  * Add a table to track Solr servers.
  */
 function apachesolr_update_7000() {
+  if (variable_get('apachesolr_update_from_6303', FALSE)) {
+    return;
+  }
 
   $schema['apachesolr_server'] = array(
     'description' => 'The Solr server table.',
@@ -363,6 +367,10 @@ function apachesolr_update_7000() {
  * Re-jigger the schema to use fewer, shorter keys.
  */
 function apachesolr_update_7001() {
+  if (variable_get('apachesolr_update_from_6303', FALSE)) {
+    return;
+  }
+
   if (db_field_exists('apachesolr_server', 'asid')) {
     // You installed the beta1 and need to be fixed up.
     db_drop_field('apachesolr_server', 'asid');
@@ -383,6 +391,10 @@ function apachesolr_update_7001() {
  * Create the per-server variable table.
  */
 function apachesolr_update_7002() {
+  if (variable_get('apachesolr_update_from_6303', FALSE)) {
+    return;
+  }
+
   $schema['apachesolr_server_variable'] = array(
     'description' => 'Variable values for each Solr server.',
     'fields' => array(
@@ -434,6 +446,10 @@ function apachesolr_update_7002() {
  * Move excluded comment types into a new variable.
  */
 function apachesolr_update_7003() {
+  if (variable_get('apachesolr_update_from_6303', FALSE)) {
+    return;
+  }
+
   // Same as apachesolr_update_6006()
   $exclude_comment_types = variable_get('apachesolr_exclude_comments_types', NULL);
   if (is_array($exclude_comment_types)) {
@@ -450,6 +466,10 @@ function apachesolr_update_7003() {
  * Update apachesolr_failure variable.
  */
 function apachesolr_update_7004() {
+  if (variable_get('apachesolr_update_from_6303', FALSE)) {
+    return;
+  }
+
   $failure = variable_get('apachesolr_failure', NULL);
   switch ($failure) {
     case 'show_error':
@@ -468,6 +488,10 @@ function apachesolr_update_7004() {
  * Re-jigger the schema to use just a url column.
  */
 function apachesolr_update_7005() {
+  if (variable_get('apachesolr_update_from_6303', FALSE)) {
+    return;
+  }
+
   if (db_field_exists('apachesolr_server', 'port')) {
     // You installed the beta3 and need to be fixed up.
     $servers = db_query('SELECT * FROM {apachesolr_server}')->fetchAllAssoc('server_id', PDO::FETCH_ASSOC);
@@ -497,6 +521,10 @@ function apachesolr_update_7005() {
  * Remove facet-related variable deprecated by the Facet API integration.
  */
 function apachesolr_update_7006() {
+  if (variable_get('apachesolr_update_from_6303', FALSE)) {
+    return;
+  }
+
   variable_del('apachesolr_facetstyle');
   variable_del('apachesolr_facet_show_children');
   variable_del('apachesolr_facet_query_limits');
@@ -507,6 +535,10 @@ function apachesolr_update_7006() {
  * Rename tables to make them more generic.
  */
 function apachesolr_update_7007() {
+  if (variable_get('apachesolr_update_from_6303', FALSE)) {
+    return;
+  }
+
   db_drop_primary_key('apachesolr_server');
   db_drop_primary_key('apachesolr_server_variable');
   db_rename_table('apachesolr_server', 'apachesolr_environment');
@@ -536,6 +568,10 @@ function apachesolr_update_7007() {
  * Remove more facet-related variable deprecated by the Facet API integration.
  */
 function apachesolr_update_7008() {
+  if (variable_get('apachesolr_update_from_6303', FALSE)) {
+    return;
+  }
+
   variable_del('apachesolr_facet_missing');
   variable_del('apachesolr_facet_query_initial_limits');
   variable_del('apachesolr_facet_query_sorts');
@@ -547,6 +583,10 @@ function apachesolr_update_7008() {
  * Update Facet API block deltas to account for removal of numeric ID from field names.
  */
 function apachesolr_update_7009() {
+  if (variable_get('apachesolr_update_from_6303', FALSE)) {
+    return;
+  }
+
   // Only run when facetapi is available and/or installed
   if (module_exists('facetapi')) {
     module_load_include('inc', 'facetapi', 'facetapi.block');
@@ -579,6 +619,10 @@ function apachesolr_update_7009() {
  * Update cache table schema for Drupal 7.
  */
 function apachesolr_update_7010() {
+  if (variable_get('apachesolr_update_from_6303', FALSE)) {
+    return;
+  }
+
   db_drop_field('cache_apachesolr', 'headers');
   return 'Updated cache table schema for Drupal 7.';
 }
@@ -587,6 +631,10 @@ function apachesolr_update_7010() {
  * Change the namespace for the indexer from apachesolr_search to apachesolr
  */
 function apachesolr_update_7011() {
+  if (variable_get('apachesolr_update_from_6303', FALSE)) {
+    return;
+  }
+
   $stored = variable_get('apachesolr_index_last', array());
   if (isset($stored['apachesolr_search'])) {
     $stored['apachesolr'] = $stored['apachesolr_search'];
@@ -600,6 +648,10 @@ function apachesolr_update_7011() {
  * Rename some variables and update the database tables
  */
 function apachesolr_update_7012() {
+  if (variable_get('apachesolr_update_from_6303', FALSE)) {
+    return;
+  }
+
   // @see: drupal_load()
   if (!function_exists('apachesolr_default_environment')) {
     include_once dirname(__FILE__) . '/apachesolr.module';
@@ -770,6 +822,10 @@ function apachesolr_update_7012() {
  * Make consistent (and reduce) field lengths which cause excess pkey length.
  */
 function apachesolr_update_7013() {
+  if (variable_get('apachesolr_update_from_6303', FALSE)) {
+    return;
+  }
+
   db_drop_primary_key('apachesolr_index_entities');
   db_change_field('apachesolr_index_entities', 'entity_type', 'entity_type', array(
     'description' => 'The type of entity.',
@@ -804,6 +860,10 @@ function apachesolr_update_7013() {
  * Remove status from the key.
  */
 function apachesolr_update_7014() {
+  if (variable_get('apachesolr_update_from_6303', FALSE)) {
+    return;
+  }
+
   $types = array(
     'other' => 'apachesolr_index_entities',
     'node' => 'apachesolr_index_entities_node',
@@ -819,7 +879,21 @@ function apachesolr_update_7014() {
  * Fix primary key schema mismatch for those who cleanly installed with beta16.
  */
 function apachesolr_update_7015() {
+  if (variable_get('apachesolr_update_from_6303', FALSE)) {
+    return;
+  }
+
   // Brand new installations since update_7013 have the wrong primary key.
   db_drop_primary_key('apachesolr_index_entities');
   db_add_primary_key('apachesolr_index_entities', array('entity_id', 'entity_type'));
 }
+
+/**
+ * Clean up apachesolr_update_from_6303.
+ *
+ * This variable had been used to bypass 7.x-1.x updates which are redundant
+ * with 6.x-3.x.
+ */
+function apachesolr_update_7016() {
+  variable_del('apachesolr_update_from_6303');
+}
-- 
1.7.10.2 (Apple Git-33)

