function apachesolr_requirements in Apache Solr Search 6
Same name and namespace in other branches
- 8 apachesolr.install \apachesolr_requirements()
- 5.2 apachesolr.install \apachesolr_requirements()
- 5 apachesolr.module \apachesolr_requirements()
- 6.3 apachesolr.install \apachesolr_requirements()
- 6.2 apachesolr.install \apachesolr_requirements()
- 7 apachesolr.install \apachesolr_requirements()
Implementation of hook_requirements().
1 call to apachesolr_requirements()
- apachesolr_settings in ./
apachesolr.admin.inc - @file Administrative pages for the Apache Solr framework.
File
- ./
apachesolr.install, line 11 - Install and related hooks for apachesolr_search.
Code
function apachesolr_requirements($phase) {
$requirements = array();
$file_exists = file_exists(dirname(__FILE__) . '/SolrPhpClient/Apache/Solr/Service.php');
// Ensure translations don't break at install time
$t = get_t();
if ($phase == 'runtime' && $file_exists) {
$host = variable_get('apachesolr_host', 'localhost');
$port = variable_get('apachesolr_port', 8983);
$path = variable_get('apachesolr_path', '/solr');
$ping = FALSE;
try {
$solr = apachesolr_get_solr();
$ping = @$solr
->ping(variable_get('apachesolr_ping_timeout', 4));
// If there is no $solr object, there is no server available, so don't continue.
if (!$ping) {
throw new Exception(t('No Solr instance available when checking requirements.'));
}
} catch (Exception $e) {
watchdog('Apache Solr', nl2br(check_plain($e
->getMessage())), NULL, WATCHDOG_ERROR);
}
$value = $ping ? $t('Your site has contacted the Apache Solr server.') : $t('Your site was unable to contact the Apache Solr server.');
$severity = $ping ? REQUIREMENT_OK : REQUIREMENT_ERROR;
$description = theme('item_list', array(
$t('Host: %host', array(
'%host' => $host,
)),
$t('Port: %port', array(
'%port' => $port,
)),
$t('Path: %path', array(
'%path' => $path,
)),
));
$requirements['apachesolr'] = array(
'title' => $t('Apache Solr'),
'value' => $value,
'description' => $description,
'severity' => $severity,
);
}
// All phases
$title = $t('Apache Solr PHP Client Library');
if ($file_exists) {
$expected_revision = 'Revision: 22';
require_once 'SolrPhpClient/Apache/Solr/Service.php';
$revision = defined('Apache_Solr_Service::SVN_REVISION') ? trim(Apache_Solr_Service::SVN_REVISION, ' $') : '';
if ($revision == $expected_revision) {
$severity = REQUIREMENT_OK;
$value = $t('Correct version "@expected".', array(
'@expected' => $expected_revision,
));
$description = NULL;
}
else {
$value = $t('Incorrect version "@version". See the instructions in README.txt.', array(
'@version' => $revision,
));
$description = $t('The version of the library in the SolrPhpClient directory is "@version" compared to the expected "@expected"', array(
'@version' => $revision,
'@expected' => $expected_revision,
));
$severity = REQUIREMENT_ERROR;
}
$requirements['SolrPhpClient'] = array(
'title' => $title,
'value' => $value,
'description' => $description,
'severity' => $severity,
);
}
else {
$requirements['SolrPhpClient'] = array(
'title' => $title,
'value' => $t('<em>Missing</em>. See the instructions in README.txt'),
'description' => $t('The Solr PHP library must be present in a sub-directory named SolrPhpClient.'),
'severity' => REQUIREMENT_ERROR,
);
}
return $requirements;
}