You are here

function panopoly_search_update_7004 in Panopoly Search 7

Panopoly RC4 Update: Disabling the Search API Solr System

File

./panopoly_search.install, line 102
Installation file for Panopoly Search

Code

function panopoly_search_update_7004(&$sandbox) {

  // If we are running on Pantheon...
  if (variable_get('pantheon_tier')) {

    // Detect if we are using search_api_solr 1.0-rc3 or lower, which used the
    // SolrPhpClient library to contact the SOLR server.
    if (function_exists('_search_api_solr_autoload')) {

      // Load the Solr PHP Client Library
      _search_api_solr_autoload('Apache_Solr_Service');
      _search_api_solr_autoload('Apache_Solr_HttpTransport_Abstract');
    }

    // Disable Panopoly's Solr Server and Solr Index
    require_once drupal_get_path('module', 'search_api') . '/search_api.admin.inc';
    if ($solr_server->enabled) {
      $solr_server = search_api_server_load('solr_server');
      $solr_server
        ->update(array(
        'enabled' => 0,
      ));
    }
    if ($solr_index->enabled) {
      $solr_index = search_api_index_load('node_index');
      $solr_index
        ->update(array(
        'enabled' => 0,
      ));
    }
    return t('Panopoly\'s Search API Solr index has been temporarily disabled on Pantheon. Search API DB will now be used for faceted search results.');
  }
}