From bd563663744fa304e40d94cdf58ad970e1d6caf1 Mon Sep 17 00:00:00 2001 From: Paul Holden Date: Fri, 18 Feb 2022 11:35:18 +0000 Subject: [PATCH] MDL-72734 tool_task: replace usage of non-existing method. The method `$task->can_run()` exists only in the master branch, replace usage with implementation appropriate for 311. --- admin/tool/task/schedule_task.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/admin/tool/task/schedule_task.php b/admin/tool/task/schedule_task.php index 68b5ebd231a..1c72eb4fd8c 100644 --- a/admin/tool/task/schedule_task.php +++ b/admin/tool/task/schedule_task.php @@ -54,8 +54,12 @@ if (!$task) { throw new moodle_exception('cannotfindinfo', 'error', new moodle_url('/admin/tool/task/scheduledtasks.php'), $taskname); } +$plugininfo = core_plugin_manager::instance()->get_plugin_info($task->get_component()); +$plugindisabled = $plugininfo && $plugininfo->is_enabled() === false && + !$task->get_run_if_component_disabled(); + $canruntasks = \core\task\manager::is_runnable() && get_config('tool_task', 'enablerunnow'); -if (!$canruntasks || !$task->can_run()) { +if (!$canruntasks || $plugindisabled) { throw new moodle_exception('nopermissions', 'error', new moodle_url('/admin/tool/task/scheduledtasks.php'), get_string('runnow', 'tool_task'), $task->get_name()); }