You are here

function search_api_acquia_override_server in Acquia Search for Search API 7.2

Overrides settings for a server.

4 calls to search_api_acquia_override_server()
SearchApiAcquiaUnitTestCase::testApacheSolrOverride in tests/search_api_acquia.test
Tests that Search API Acquia properly overrides the connection details to avoid unintended writing to a wrong search index.
SearchApiAcquiaUnitTestCase::testApacheSolrOverrideWhenCoreWithDbNameNotAvailable in tests/search_api_acquia.test
Tests that it selects the correct preferred search core ID for the override URL when limited number of core ID is available.
SearchApiAcquiaUnitTestCase::testApacheSolrOverrideWithUnderscoreInDb in tests/search_api_acquia.test
Tests that Search API Acquia properly overrides the connection details to avoid unintended writing to a wrong search index and db.
search_api_acquia_add_solr_overrides in ./search_api_acquia.module
Overrides search_api_solr configs to talk to the proper Acquia search core.

File

./search_api_acquia.module, line 110
Provides integration between your Drupal site and Acquia's hosted search service via the Search API Solr module.

Code

function search_api_acquia_override_server($core_service, $server_id) {
  global $conf;

  // Skip if the Search API server has already been overridden.
  if (!empty($conf['search_api_acquia_overrides'][$server_id])) {
    if (empty($conf['search_api_acquia_overrides'][$server_id]['overridden_by_acquia_search'])) {
      $conf['search_api_acquia_overrides'][$server_id]['overridden_by_acquia_search'] = SEARCH_API_ACQUIA_EXISTING_OVERRIDE;
    }
    return FALSE;
  }
  $conf['search_api_acquia_overrides'][$server_id]['acquia_search_possible_cores'] = $core_service
    ->getListOfPossibleCores();
  if ($core_service
    ->isPreferredCoreAvailable()) {
    $derived_key = search_api_acquia_get_derived_key_for_core($core_service
      ->getPreferredCoreId());
    $conf['search_api_acquia_overrides'][$server_id]['path'] = '/solr/' . $core_service
      ->getPreferredCoreId();
    $conf['search_api_acquia_overrides'][$server_id]['host'] = $core_service
      ->getPreferredCoreHostname();
    $conf['search_api_acquia_overrides'][$server_id]['derived_key'] = $derived_key;
    $conf['search_api_acquia_overrides'][$server_id]['overridden_by_acquia_search'] = SEARCH_API_ACQUIA_OVERRIDE_AUTO_SET;
    return TRUE;
  }

  // At this point none of the available search cores match to what is
  //   expected, so read-only mode should be set.
  // Read only mode is actually set per-index during
  //   search_api_acquia_search_api_index_load(), however we add a diagnostic
  //   value here for testing.
  if (!variable_get('acquia_search_disable_auto_read_only', 0)) {
    $conf['search_api_acquia_overrides'][$server_id]['overridden_by_acquia_search'] = SEARCH_API_ACQUIA_AUTO_SHOULD_OVERRIDE_READ_ONLY;
    return TRUE;
  }
  return FALSE;
}