You are here

function apachesolr_failure in Apache Solr Search 6.3

Same name and namespace in other branches
  1. 8 apachesolr.module \apachesolr_failure()
  2. 5.2 apachesolr.module \apachesolr_failure()
  3. 5 apachesolr.module \apachesolr_failure()
  4. 6 apachesolr.module \apachesolr_failure()
  5. 6.2 apachesolr.module \apachesolr_failure()
  6. 7 apachesolr.module \apachesolr_failure()

Determines Apache Solr's behavior when searching causes an exception (e.g. Solr isn't available.) Depending on the admin settings, possibly redirect to Drupal's core search.

Parameters

$search_name: The name of the search implementation.

$querystring: The search query that was issued at the time of failure.

1 call to apachesolr_failure()
apachesolr_search_search_results in ./apachesolr_search.module
2 string references to 'apachesolr_failure'
apachesolr_settings in ./apachesolr.admin.inc
Form builder for general settings used as a menu callback.
apachesolr_uninstall in ./apachesolr.install
Implements hook_uninstall(). @todo : Remove the blocks with a query

File

./apachesolr.module, line 591
Integration with the Apache Solr search application.

Code

function apachesolr_failure($search_name, $querystring) {
  $fail_rule = variable_get('apachesolr_failure', 'apachesolr:show_error');
  switch ($fail_rule) {
    case 'apachesolr:show_error':
      drupal_set_message(t('Search is temporarily unavailable. If the problem persists, please contact the site administrator.'), 'error');
      break;
    case 'apachesolr:show_no_results':

      // Do nothing.
      break;
    default:

      // If we're failing over to another module make sure the search is available.
      if (module_exists('search')) {
        drupal_set_message(t("%search_name is not available. Your search is being redirected.", array(
          '%search_name' => $search_name,
        )));
        drupal_goto('search/node/' . drupal_urlencode($querystring));
      }

      // if search is not enabled, break and do nothing
      break;
  }
}