MDL-53247 search: Require search to be available before running indexer script
authorDavid Monllao <davidm@moodle.com>
Wed, 9 Mar 2016 05:37:33 +0000 (13:37 +0800)
committerDavid Monllao <davidm@moodle.com>
Wed, 9 Mar 2016 05:37:33 +0000 (13:37 +0800)
search/cli/indexer.php

index b40a20b..f42b8e9 100644 (file)
@@ -56,6 +56,17 @@ if (!\core_search\manager::is_global_search_enabled() && empty($options['force']
     cli_error('Global search is disabled. Use --force if you want to force an index while disabled');
 }
 
+if (!$searchengine = \core_search\manager::search_engine_instance()) {
+    cli_error(get_string('engineserverstatus', 'search'));
+}
+if (!$searchengine->is_installed()) {
+    cli_error('enginenotinstalled', 'search', $CFG->searchengine);
+}
+$serverstatus = $searchengine->is_server_ready();
+if ($serverstatus !== true) {
+    cli_error($serverstatus);
+}
+
 $globalsearch = \core_search\manager::instance();
 
 if (empty($options['reindex'])) {