MDL-55287 search: Check that an engine has been selected
authorDavid Monllao <davidm@moodle.com>
Wed, 20 Jul 2016 09:26:14 +0000 (11:26 +0200)
committerDavid Monllao <davidm@moodle.com>
Thu, 21 Jul 2016 16:40:29 +0000 (18:40 +0200)
admin/searchareas.php
lang/en/search.php
search/classes/manager.php

index 884d5b8..dcbc7cb 100644 (file)
@@ -95,7 +95,7 @@ if (empty($searchmanagererror)) {
 }
 
 if (!empty($searchmanagererror)) {
-    $errorstr = get_string($searchmanagererror->errorcode, $searchmanagererror->module);
+    $errorstr = get_string($searchmanagererror->errorcode, $searchmanagererror->module, $searchmanagererror->a);
     echo $OUTPUT->notification($errorstr, \core\output\notification::NOTIFY_ERROR);
 } else {
     echo $OUTPUT->notification(get_string('indexinginfo', 'admin'), \core\output\notification::NOTIFY_INFO);
index bfe296c..f9e4da9 100644 (file)
@@ -47,7 +47,8 @@ $string['documentsinindex'] = 'Documents in index';
 $string['duration'] = 'Duration';
 $string['emptydatabaseerror'] = 'Database table is not present, or contains no index records.';
 $string['enginenotfound'] = 'Engine {$a} not found.';
-$string['enginenotinstalled'] = '{$a} not installed.';
+$string['enginenotinstalled'] = 'Engine {$a} 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';
 $string['errors'] = 'Errors';
index cf164b8..6478c0e 100644 (file)
@@ -122,6 +122,10 @@ class manager {
             return static::$instance;
         }
 
+        if (empty($CFG->searchengine)) {
+            throw new \core_search\engine_exception('enginenotselected', 'search');
+        }
+
         if (!$engine = static::search_engine_instance()) {
             throw new \core_search\engine_exception('enginenotfound', 'search', '', $CFG->searchengine);
         }