Commit d761b3fb authored by sam marshall's avatar sam marshall
Browse files

MDL-55356 core_search: API to check if indexing enabled

New function \core_search\manager::is_indexing_enabled(), analagous
to existing is_global_search_enabled().

This replaces existing duplicated code, ready for more use in
following commits.
parent 0da8f62f
......@@ -46,8 +46,7 @@ class search_index_task extends scheduled_task {
* Throw exceptions on errors (the job will be retried).
*/
public function execute() {
if (!\core_search\manager::is_global_search_enabled() &&
!get_config('core', 'searchindexwhendisabled')) {
if (!\core_search\manager::is_indexing_enabled()) {
return;
}
$globalsearch = \core_search\manager::instance();
......
......@@ -49,8 +49,7 @@ class search_optimize_task extends scheduled_task {
* Throw exceptions on errors (the job will be retried).
*/
public function execute() {
if (!\core_search\manager::is_global_search_enabled() &&
!get_config('core', 'searchindexwhendisabled')) {
if (!\core_search\manager::is_indexing_enabled()) {
return;
}
......
......@@ -157,6 +157,17 @@ class manager {
return !empty($CFG->enableglobalsearch);
}
/**
* Returns whether indexing is enabled or not (you can enable indexing even when search is not
* enabled at the moment, so as to have it ready for students).
*
* @return bool True if indexing is enabled.
*/
public static function is_indexing_enabled() {
global $CFG;
return !empty($CFG->enableglobalsearch) || !empty($CFG->searchindexwhendisabled);
}
/**
* Returns an instance of the search engine.
*
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment