You are here

function apachesolr_failure in Apache Solr Search 7

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.3 apachesolr.module \apachesolr_failure()
  5. 6 apachesolr.module \apachesolr_failure()
  6. 6.2 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
Executes search depending on the conditions given. See apachesolr_search.pages.inc for another use of this function
3 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().
apachesolr_update_7004 in ./apachesolr.install
Update apachesolr_failure variable.

File

./apachesolr.module, line 542
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')) {
        $search_info = search_get_info();
        if (isset($search_info[$fail_rule])) {
          $search_info = $search_info[$fail_rule];
          drupal_set_message(t("%search_name is not available. Your search is being redirected.", array(
            '%search_name' => $search_name,
          )));
          drupal_goto('search/' . $search_info['path'] . '/' . rawurlencode($querystring));
        }
      }

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