mirror of
https://github.com/moodle/moodle.git
synced 2025-08-09 10:56:56 +02:00
MDL-46207 Tasks: Do not run tasks if their component is disabled.
This can be overridden on a per task basis by implementing: get_run_if_component_disabled() in the scheduled task.
This commit is contained in:
parent
584539c0fc
commit
fd57c17e2d
2 changed files with 22 additions and 0 deletions
|
@ -456,6 +456,8 @@ class manager {
|
|||
$params = array('timestart1' => $timestart, 'timestart2' => $timestart);
|
||||
$records = $DB->get_records_select('task_scheduled', $where, $params);
|
||||
|
||||
$pluginmanager = \core_plugin_manager::instance();
|
||||
|
||||
foreach ($records as $record) {
|
||||
|
||||
if ($lock = $cronlockfactory->get_lock(($record->classname), 10)) {
|
||||
|
@ -463,6 +465,17 @@ class manager {
|
|||
$task = self::scheduled_task_from_record($record);
|
||||
|
||||
$task->set_lock($lock);
|
||||
|
||||
// See if the component is disabled.
|
||||
$plugininfo = $pluginmanager->get_plugin_info($task->get_component());
|
||||
|
||||
if ($plugininfo) {
|
||||
if (!$task->get_run_if_component_disabled() && !$plugininfo->is_enabled()) {
|
||||
$lock->release();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$task->is_blocking()) {
|
||||
$cronlock->release();
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue