Commit Graph

227 Commits

Author SHA1 Message Date
Andrew Nicols cd4e7f3fe6 Merge branch 'MDL-80684-MOODLE_402_STABLE-fail_running_tasks_on_shutdown' of https://github.com/praxisdigital/moodle into MOODLE_402_STABLE 2024-02-28 14:21:13 +08:00
Andrew Nicols 70b7730827 MDL-80862 testing: Reset task manager between behat tests 2024-02-20 10:54:55 +08:00
Frederik Milling Pytlick cc96965b3b MDL-80684 core: Fail running tasks on shutdown
When you kill a process which is executing a task, it now marks it as failed.
2024-02-19 12:03:51 +01:00
Andrew Nicols d036e5e3fd Merge branch 'MDL-80667-402' of https://github.com/paulholden/moodle into MOODLE_402_STABLE 2024-02-08 16:13:01 +08:00
Huong Nguyen 06802bd46d MDL-74775 adhoc_task: Do not clear the timecreated of failed tasks 2024-01-29 10:03:17 +07:00
Ilya Tregubov c28c449259 Merge branch 'MDL-75579-402' of https://github.com/HuongNV13/moodle into MOODLE_402_STABLE 2024-01-23 12:05:02 +08:00
Huong Nguyen 922471c050 MDL-75579 Backup: Prevent failed course restore task to be retried 2024-01-23 09:34:12 +07:00
Huong Nguyen ca05ed2c18 MDL-75579 adhoc_task: Implement no-retry flag 2024-01-23 09:34:12 +07:00
Jun Pataleta 352b995cb9 Merge branch 'MDL-80323-402' of https://github.com/paulholden/moodle into MOODLE_402_STABLE 2024-01-22 16:26:00 +08:00
Paul Holden 70cee4252f MDL-80667 task: preserve environment when running tasks from web.
For sites that rely on environment variables to set configuration,
ensure they are also present when executing task process.

Co-authored-by: Olivier Wenger <olivier.wenger@liip.ch>
2024-01-18 16:54:08 +00:00
Ilya Tregubov 0852082960 Merge branch 'MDL-69615-402' of https://github.com/HuongNV13/moodle into MOODLE_402_STABLE 2024-01-16 10:58:09 +08:00
Huong Nguyen 0ba6c2d20c MDL-69615 core_backup: Send backup report email once the tasks are done 2024-01-16 09:31:36 +07:00
Sara Arjona 57dd86d987 Merge branch 'MDL-79091-MOODLE_402_STABLE' of https://github.com/jay-oswald/moodle into MOODLE_402_STABLE 2024-01-15 12:31:47 +01:00
Huong Nguyen 88814648a6 MDL-69615 core_task: Add a task trait 2024-01-15 11:26:26 +07:00
Paul Holden a85e2ca6ca MDL-80323 h5p: fail content type retrieval task on errors.
It's better for the task to fail gracefully rather than silently
swallow any errors, so that the task API can schedule re-tries.

If the endpoint is temporarily down and/or misbehaving, this will
allow admins to have clearer failures.
2024-01-08 10:06:43 +00:00
Brendan Heywood e5fc6edb1d MDL-80309 tasks: Clean up mtrace logs 2023-12-07 12:07:55 +08:00
Jay Oswald 04b4eeb16a MDL-79091 core_badges: refactor bades cron task 2023-11-30 17:24:29 +11:00
Jay Oswald d70903a077 MDL-79091 core_badges: use adhoc tasks 2023-11-30 17:24:29 +11:00
sam marshall edb057d922 MDL-79966 core_task: NEVER_RUN_TIME did not fit in 10 digits 2023-11-23 16:24:15 +00:00
sam marshall 8f01753027 MDL-79966 core_task: Scheduled task timing (crontab fields) is wrong 2023-11-20 17:11:32 +00:00
Paul Holden 962c23a4d5 MDL-79186 task: fix evaluation of 'X/Y' cron field format.
The above syntax is defined as supported by the class, for example the
format '5/10' means:

"At every 10th <unit> from 5 through <max>."

It is analogous to '5-<max>/10'.
2023-09-11 09:22:21 +01:00
Paul Holden 64734d59af MDL-74824 user: fix custom change password URL in login notification. 2023-06-11 17:41:01 +01:00
Tim Hunt 4d263b0505 MDL-75576 quiz/question statistics: don't expire by time
Previously, a set of calculated quiz statistics would only 'last' for
15 minutes. Then they would be considered invalid and not used.

Now, computed statistics are kept indefinitely. Instead, when a new
batch of values are computed for a particular set of settings, older numbers
for the same settings are deleted first. Therefore,
question_stats_cleanup_task is no more.
2023-05-15 10:03:27 +01:00
Sara Arjona 9ce4fb65fd Merge branch 'MDL-77164-master' of https://github.com/marinaglancy/moodle 2023-04-13 14:00:18 +02:00
Marina Glancy 8fc1486d36 MDL-77164 various: fix incorrect phpdocs 2023-04-13 11:35:06 +01:00
Srdjan 85323070e7 MDL-70975 task: adhoctasks.php - queued ad hoc tasks report
Similar to scheduled tasks report

core\task\manager::adhoc_task_from_record() now raises moodle_exception
2023-04-05 11:29:46 +10:00
Srdjan 6d9aaa8412 MDL-70975 task: Support for running only failed ad hoc tasks
* CLI adhoc_task.php: new option --failed
2023-04-05 11:05:23 +10:00
Srdjan 3491ea1650 MDL-70975 task: Support for running adhoc tasks filtered by class
* CLI adhoc_task.php: new option --classname
* core\task\manager::get_next_adhoc_task(): new param $classname
  for filtering tasks
2023-04-05 11:00:46 +10:00
Srdjan 9405b5aa6d MDL-70975 task: Support for running adhoc tasks by id
* CLI adhoc_task.php: new option --id
* cron::run_adhoc_task($taskid) for running tasks by id
* core\task\manager::get_adhoc_task($taskid) for retreival/locking
2023-04-05 10:55:18 +10:00
Andrew Nicols 9ec46c232d MDL-77186 core: Move all uses of cronlib to new class 2023-03-13 21:21:13 +08:00
Andrew Nicols a3cc26f8bb MDL-76583 core: Update uses of external_* classes 2023-01-19 07:34:09 +08:00
Qihui Chan 791e56d3bc MDL-72775 tool_task: check long running tasks 2022-12-23 09:41:05 +10:00
Marina Glancy 741b3572cc MDL-73421 core: Calling static method on trait deprecated in PHP8.1 2022-09-16 15:04:02 +02:00
Paul Holden 91ae2c25b4 MDL-75308 task: explicit check for tasks of disabled plugins.
The enabled state of a plugin is a tri-state value (boolean or
null). We should be consistent with elsewhere by only considering
boolean false as an actually disabled plugin.

See also cdcb53a1 for similar change in task management.
2022-08-30 13:04:06 +01:00
Paul Holden d0b5241786 MDL-75256 task: move abstract get_name method to base class.
Allow adhoc tasks to implement this method, so they too can have
descriptive names for themselves. Default implementation added to
return the class name itself.
2022-07-22 09:13:53 +01:00
Cameron Ball 29df52af19 MDL-74548 backup: Refactor course copies
This patch modifies the way copy data is shared in order to mitigate potential race conditions
and ensure that the serialised controller stored in the DB is always in a valid state.

The restore controller is now considered the "source of truth" for all information about the
copy operation. Backup controllers can no longer contain information about course copies.

As copy creation is not atomic, it is still possible for copy controllers to become orphaned or
exist in an invalid state. To mitigate this the backup cleanup task has been modified to call
a new helper method copy_helper::cleanup_orphaned_copy_controllers.

Summary of changes in this patch:

    - Copy data must now be passed through the restore controller's constructor
    - base_controller::get_copy has been deprecated in favour of restore_controller::get_copy
    - base_controller::set_copy has been deprecated without replacement
    - core_backup\copy\copy has been deprecated, use copy_helper.class.php's copy_helper instead
    - backup_cleanup_task will now clean up orphaned controllers from copy operations that went awry

Thanks to Peter Burnett for assiting with testing this patch.
2022-06-29 09:13:29 +08:00
Ilya Tregubov 41cf7a58f1 MDL-73293 core_task: patch for undefined propety. 2022-06-15 11:31:31 +04:00
Cameron Ball cd1a7291ea MDL-73293 core_task: Cleanup stale adhoc task metadata 2022-06-09 14:15:37 +08:00
Ilya Tregubov 0460147cb5 Merge branch 'MDL-67648-master' of https://github.com/cameron1729/moodle 2022-05-27 15:41:29 +06:00
Peter Burnett 3801662e97 MDL-71198 backup: Change times on restore file duplication 2022-05-25 22:18:36 +08:00
Cameron Ball 8154aa2e03 MDL-67648 tasks: Fair-share scheduling with resource management
This patch changes the way adhoc tasks are chosen to run. It now calculates
how many runners each type of adhoc task should be allowed to use. In the
case that not all the runners are utilised, it attempts to infer which
tasks do not take a long time to run, and gives those to the vacant runners.

Thanks to Brendan Heywood for guidance and SQL help.
2022-05-25 09:38:41 +08:00
Paul Holden 4102ae35a4 MDL-74283 dml: replace hardcoded concat SQL with appropriate API. 2022-03-22 17:33:03 +00:00
Sara Arjona a221c171f0 Merge branch 'MDL-74183-master' of https://github.com/ericmerrill/moodle 2022-03-21 12:41:10 +01:00
Eric Merrill f3ea6862aa MDL-74183 completion: Protect against index conflict in cron 2022-03-14 22:56:20 -04:00
Sara Arjona 730bc8735e MDL-74141 tool_task: Display error when Path to CLI not defined
When "Path to PHP CLI" is not defined, an exception with the message
in cannotfindthepathtothecli should be displayed, and the page should
be redirected to System paths settings page.

Apart from that, this patch also replaced core_task to tool_task,
because this message wasn't traslated properly.
2022-03-10 16:19:07 +01:00
Jordi Pujol Ahulló 21f73b29c1 MDL-69764 tool_task: unify crontab verification
Use scheduled_task crontab field verification in
admin/tool/task to unify how Moodle deals with
crontab definition and its verification.
This helps remove duplicated code and fix
crontab definition not allowed in the web form,
but actually was valid.

Updated crontab fields precision on task_scheduled
table to have enough room for the worst case:
all possible different values separated by comma.
2022-02-17 13:24:31 +01:00
David Mudrák 296f714916 MDL-73765 task: Fix calculation of random minute in the task schedule
The random minute was incorrectly set to a random value from the range
0 - 23 instead of 0 - 59 due to this copy & paste mistake.
2022-02-03 19:22:58 +01:00
Jun Pataleta 0dcfa504a0 Merge branch 'MDL-68773-clear-adhoc-tasks' of https://github.com/Peterburnett/moodle 2022-01-05 18:47:01 +08:00
Peter Burnett 28d6333f47 MDL-68773 backup: Allow completed async backup + restore tasks to clear 2022-01-04 10:57:58 +10:00
Brendan Heywood a113af2446 MDL-73207 cron: Fixed cronspec field order bug 2021-12-06 17:52:40 +11:00