Moodle APIs
3.8
Moodle 3.8.6 (Build: 20201109)
|
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 | 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) |
This function load the default scheduled task details for a given classname. More... | |
static | get_next_adhoc_task ($timestart) |
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 | load_default_scheduled_tasks_for_component ($componentname) |
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 | 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) |
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 | get_canonical_class_name ($taskorstring) |
Gets class name for use in database table. 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 |
|
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 |
This function load the adhoc tasks for a given classname.
string | $classname |
core |
|
static |
This function will return a list of all the scheduled tasks that exist in the database.
core |
|
staticprotected |
Gets class name for use in database table.
Always begins with a .
string | task_base | $taskorstring | Task object or a string |
|
static |
This function load the default scheduled task details for a given classname.
string | $classname |
core |
|
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 } or adhoc_task_complete to release the lock and reschedule the task.
int | $timestart |
core |
|
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 } 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 |
|
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 |
|
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. |
core |
|
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 |
|
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 |
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 |
core |
|
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 |