Skip to content

Commit

Permalink
MDL-55287 search: Custom error message if solr extension is not insta…
Browse files Browse the repository at this point in the history
…lled

Correcting engine is not installed lang string as well.
  • Loading branch information
David Monllao committed Jul 27, 2016
1 parent 379ca98 commit e240a61
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lang/en/search.php
Expand Up @@ -47,7 +47,7 @@
$string['duration'] = 'Duration';
$string['emptydatabaseerror'] = 'Database table is not present, or contains no index records.';
$string['enginenotfound'] = 'Engine {$a} not found.';
$string['enginenotinstalled'] = 'Engine {$a} not installed.';
$string['enginenotinstalled'] = 'Engine {$a} is not installed.';
$string['enginenotselected'] = 'You have not selected any search engine.';
$string['engineserverstatus'] = 'The search engine is not available. Please contact your administrator.';
$string['enteryoursearchquery'] = 'Enter your search query';
Expand Down
6 changes: 5 additions & 1 deletion lib/adminlib.php
Expand Up @@ -9741,7 +9741,11 @@ public function output_html($data, $query='') {
array('href' => $url));
// Check the engine status.
$searchengine = \core_search\manager::search_engine_instance();
$serverstatus = $searchengine->is_server_ready();
try {
$serverstatus = $searchengine->is_server_ready();
} catch (\moodle_exception $e) {
$serverstatus = $e->getMessage();
}
if ($serverstatus === true) {
$status = html_writer::tag('span', get_string('yes'), array('class' => 'statusok'));
} else {
Expand Down
4 changes: 4 additions & 0 deletions search/engine/solr/classes/engine.php
Expand Up @@ -1160,6 +1160,10 @@ protected function get_search_client($triggerexception = true) {
'timeout' => !empty($this->config->server_timeout) ? $this->config->server_timeout : '30'
);

if (!class_exists('\SolrClient')) {
throw new \core_search\engine_exception('enginenotinstalled', 'search', '', 'solr');
}

$client = new \SolrClient($options);

if ($client === false && $triggerexception) {
Expand Down

0 comments on commit e240a61

Please sign in to comment.