Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
|
Collection of task related methods. More...
Static Public Member Functions | |
static | adhoc_task_complete (adhoc_task $task) |
This function indicates that an adhoc task was completed successfully. More... | |
static | adhoc_task_failed (adhoc_task $task) |
This function indicates that an adhoc task was not completed successfully and should be retried. More... | |
static | adhoc_task_from_record ($record) |
Utility method to create an adhoc task from a DB record. More... | |
static | clear_fail_delay (scheduled_task $task) |
Clears the fail delay for the given task and updates its next run time based on the schedule. More... | |
static | clear_static_caches () |
This function is used to indicate that any long running cron processes should exit at the next opportunity and restart. More... | |
static | configure_scheduled_task (scheduled_task $task) |
Change the default configuration for a scheduled task. More... | |
static | ensure_adhoc_task_qos (array $records) |
Ensure quality of service for the ad hoc task queue. More... | |
static | get_adhoc_tasks ($classname) |
This function load the adhoc tasks for a given classname. More... | |
static | get_all_scheduled_tasks () |
This function will return a list of all the scheduled tasks that exist in the database. More... | |
static | get_default_scheduled_task ($classname, $expandr=true) |
This function load the default scheduled task details for a given classname. More... | |
static | get_next_adhoc_task ($timestart, $checklimits=true) |
This function will dispatch the next adhoc task in the queue. More... | |
static | get_next_scheduled_task ($timestart) |
This function will dispatch the next scheduled task in the queue. More... | |
static | get_scheduled_task ($classname) |
This function load the scheduled task details for a given classname. More... | |
static | is_runnable () |
Returns if Moodle have access to PHP CLI binary or not. More... | |
static | load_default_scheduled_tasks_for_component ($componentname, $expandr=true) |
Given a component name, will load the list of tasks in the db/tasks.php file for that component. More... | |
static | load_scheduled_tasks_for_component ($componentname) |
Given a component name, will load the list of tasks from the scheduled_tasks table for that component. More... | |
static | queue_adhoc_task (adhoc_task $task, $checkforexisting=false) |
Queue an adhoc task to run in the background. More... | |
static | record_from_adhoc_task ($task) |
Utility method to create a DB record from an adhoc task. More... | |
static | record_from_scheduled_task ($task) |
Utility method to create a DB record from a scheduled task. More... | |
static | reschedule_or_queue_adhoc_task (adhoc_task $task) |
Schedule a new task, or reschedule an existing adhoc task which has matching data. More... | |
static | reset_scheduled_tasks_for_component ($componentname) |
Update the database to contain a list of scheduled task for a component. More... | |
static | run_from_cli (\core\task\task_base $task) |
Executes a cron from web invocation using PHP CLI. More... | |
static | scheduled_task_complete (scheduled_task $task) |
This function indicates that a scheduled task was completed successfully and should be rescheduled. More... | |
static | scheduled_task_failed (scheduled_task $task) |
This function indicates that a scheduled task was not completed successfully and should be retried. More... | |
static | scheduled_task_from_record ($record, $expandr=true) |
Utility method to create a task from a DB record. More... | |
static | static_caches_cleared_since ($starttime) |
Return true if the static caches have been cleared since $starttime. More... | |
Static Protected Member Functions | |
static | find_php_cli_path () |
Find the path of PHP CLI binary. More... | |
static | get_canonical_class_name ($taskorstring) |
Gets class name for use in database table. More... | |
static | get_concurrent_task_lock (adhoc_task $task) |
Gets the concurrent lock required to run an adhoc task. More... | |
static | get_queued_adhoc_task_record ($task) |
Checks if the task with the same classname, component and customdata is already scheduled. More... | |
static | task_is_scheduled ($task) |
Checks if the task with the same classname, component and customdata is already scheduled. More... | |
Collection of task related methods.
Some locking rules for this class: All changes to scheduled tasks must be protected with both - the global cron lock and the lock for the specific scheduled task (in that order). Locks must be released in the reverse order.
|
static |
This function indicates that an adhoc task was completed successfully.
core::task::adhoc_task | $task |
|
static |
This function indicates that an adhoc task was not completed successfully and should be retried.
core::task::adhoc_task | $task |
|
static |
Utility method to create an adhoc task from a DB record.
stdClass | $record |
core::task::adhoc_task |
|
static |
Clears the fail delay for the given task and updates its next run time based on the schedule.
scheduled_task | $task | Task to reset |
dml_exception | If there is a database error |
|
static |
This function is used to indicate that any long running cron processes should exit at the next opportunity and restart.
This is because something (e.g. DB changes) has changed and the static caches may be stale.
|
static |
Change the default configuration for a scheduled task.
The list of scheduled tasks is taken from load_scheduled_tasks_for_component.
core::task::scheduled_task | $task | - The new scheduled task information to store. |
boolean | - True if the config was saved. |
|
static |
Ensure quality of service for the ad hoc task queue.
This reshuffles the adhoc tasks queue to balance by type to ensure a level of quality of service per type, while still maintaining the relative order of tasks queued by timestamp.
array | $records | array of task records |
array | $records | array of same task records shuffled |
|
staticprotected |
Find the path of PHP CLI binary.
string|false | The PHP CLI executable PATH |
|
static |
This function load the adhoc tasks for a given classname.
string | $classname |
core::task::adhoc_task[] |
|
static |
This function will return a list of all the scheduled tasks that exist in the database.
core::task::scheduled_task[] |
|
staticprotected |
Gets class name for use in database table.
Always begins with a .
string | task_base | $taskorstring | Task object or a string |
|
staticprotected |
Gets the concurrent lock required to run an adhoc task.
adhoc_task | $task | The task to obtain the lock for |
core::lock::lock | The lock if one was obtained successfully |
coding_exception |
|
static |
This function load the default scheduled task details for a given classname.
string | $classname | |
bool | $expandr | - if true (default) an 'R' value in a time is expanded to an appropriate int. If false, they are left as 'R' |
core::task::scheduled_task|false |
|
static |
This function will dispatch the next adhoc task in the queue.
The task will be handed out with an open lock - possibly on the entire cron process. Make sure you call either adhoc_task_failed or adhoc_task_complete to release the lock and reschedule the task.
int | $timestart | |
bool | $checklimits | Should we check limits? |
core::task::adhoc_task | or null if not found |
moodle_exception |
|
static |
This function will dispatch the next scheduled task in the queue.
The task will be handed out with an open lock - possibly on the entire cron process. Make sure you call either scheduled_task_failed or scheduled_task_complete to release the lock and reschedule the task.
int | $timestart | - The start of the cron process - do not repeat any tasks that have been run more recently than this. |
core::task::scheduled_task | or null |
moodle_exception |
|
staticprotected |
Checks if the task with the same classname, component and customdata is already scheduled.
adhoc_task | $task |
bool |
|
static |
This function load the scheduled task details for a given classname.
string | $classname |
core::task::scheduled_task | or false |
|
static |
Returns if Moodle have access to PHP CLI binary or not.
bool |
|
static |
Given a component name, will load the list of tasks in the db/tasks.php file for that component.
string | $componentname | - The name of the component to fetch the tasks for. |
bool | $expandr | - if true (default) an 'R' value in a time is expanded to an appropriate int. If false, they are left as 'R' |
core::task::scheduled_task[] | - List of scheduled tasks for this component. |
|
static |
Given a component name, will load the list of tasks from the scheduled_tasks table for that component.
Do not execute tasks loaded from this function - they have not been locked.
string | $componentname | - The name of the component to load the tasks for. |
core::task::scheduled_task[] |
|
static |
Queue an adhoc task to run in the background.
core::task::adhoc_task | $task | - The new adhoc task information to store. |
bool | $checkforexisting | - If set to true and the task with the same user, classname, component and customdata is already scheduled then it will not schedule a new task. Can be used only for ASAP tasks. |
boolean | - True if the config was saved. |
|
static |
Utility method to create a DB record from an adhoc task.
core::task::adhoc_task | $task |
stdClass |
|
static |
Utility method to create a DB record from a scheduled task.
core::task::scheduled_task | $task |
stdClass |
|
static |
Schedule a new task, or reschedule an existing adhoc task which has matching data.
Only a task matching the same user, classname, component, and customdata will be rescheduled. If these values do not match exactly then a new task is scheduled.
core::task::adhoc_task | $task | - The new adhoc task information to store. |
|
static |
Update the database to contain a list of scheduled task for a component.
The list of scheduled tasks is taken from @load_scheduled_tasks_for_component. Will throw exceptions for any errors.
string | $componentname | - The frankenstyle component name. |
|
static |
Executes a cron from web invocation using PHP CLI.
core::task::task_base | $task | Task that be executed via CLI. |
bool |
moodle_exception |
|
static |
This function indicates that a scheduled task was completed successfully and should be rescheduled.
core::task::scheduled_task | $task |
|
static |
This function indicates that a scheduled task was not completed successfully and should be retried.
core::task::scheduled_task | $task |
|
static |
Utility method to create a task from a DB record.
stdClass | $record | |
bool | $expandr | - if true (default) an 'R' value in a time is expanded to an appropriate int. If false, they are left as 'R' |
core::task::scheduled_task|false |
|
static |
Return true if the static caches have been cleared since $starttime.
int | $starttime | The time this process started. |
boolean | True if static caches need resetting. |
|
staticprotected |
Checks if the task with the same classname, component and customdata is already scheduled.
adhoc_task | $task |
bool |