Skip to content

Commit

Permalink
Merge branch 'MDL-72734-311' of https://github.com/paulholden/moodle
Browse files Browse the repository at this point in the history
…into MOODLE_311_STABLE
  • Loading branch information
andrewnicols authored and ilyatregubov committed Feb 18, 2022
2 parents 21e61a3 + 77857ce commit 3310bf9
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions admin/tool/task/schedule_task.php
Expand Up @@ -47,15 +47,17 @@ function tool_task_mtrace_wrapper($message, $eol) {
require_admin();
$context = context_system::instance();

if (!get_config('tool_task', 'enablerunnow')) {
print_error('nopermissions', 'error', '', get_string('runnow', 'tool_task'));
}

// Check input parameter against all existing tasks (this ensures it isn't possible to
// create some kind of security problem by specifying a class that isn't a task or whatever).
$task = \core\task\manager::get_scheduled_task($taskname);
if (!$task) {
print_error('cannotfindinfo', 'error', $taskname);
throw new moodle_exception('cannotfindinfo', 'error', new moodle_url('/admin/tool/task/scheduledtasks.php'), $taskname);
}

$canruntasks = \core\task\manager::is_runnable() && get_config('tool_task', 'enablerunnow');
if (!$canruntasks || !$task->can_run()) {
throw new moodle_exception('nopermissions', 'error', new moodle_url('/admin/tool/task/scheduledtasks.php'),
get_string('runnow', 'tool_task'), $task->get_name());
}

// Start output.
Expand Down

0 comments on commit 3310bf9

Please sign in to comment.