function _search_api_solr_switch_to_site_hash in Search API Solr 7
Switches a server to multi-site compatibility mode.
Used as a submit callback in SearchApiSolrService::configurationForm().
1 string reference to '_search_api_solr_switch_to_site_hash'
- SearchApiSolrService::configurationForm in includes/
service.inc - Implements SearchApiServiceInterface::__construct().
File
- ./
search_api_solr.module, line 380 - Provides a Solr-based service class for the Search API.
Code
function _search_api_solr_switch_to_site_hash(array $form, array &$form_state) {
$server = $form_state['server'];
try {
$conditions['server'] = $server->machine_name;
$indexes = search_api_index_load_multiple(FALSE, $conditions);
if ($indexes) {
foreach ($indexes as $index) {
$index
->reindex();
}
$msg = format_plural(count($indexes), '1 index was cleared.', '@count indexes were cleared.');
$server
->deleteItems('index_id:(' . implode(' ', array_keys($indexes)) . ')');
drupal_set_message($msg);
}
} catch (SearchApiException $e) {
$variables = array(
'@server' => $server->name,
);
watchdog_exception('search_api_solr', $e, '%type while attempting to enable multi-site compatibility mode for Solr server @server: !message in %function (line %line of %file).', $variables);
drupal_set_message(t('An error occured while attempting to enable multi-site compatibility mode for Solr server @server. Check the logs for details.', $variables), 'error');
return;
}
$server->options['site_hash'] = TRUE;
$server
->save();
drupal_set_message(t('The Solr server was successfully switched to multi-site compatibility mode.'));
}