mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 14:27:22 +01:00
Merge branch 'MDL-79130-master' of https://github.com/stevandoMoodle/moodle
This commit is contained in:
commit
12203eea69
@ -55,6 +55,11 @@ class manager {
|
||||
*/
|
||||
const ADHOC_TASK_FAILED_RETENTION = 4 * WEEKSECS;
|
||||
|
||||
/**
|
||||
* @var int Used for max retry.
|
||||
*/
|
||||
const MAX_RETRY = 9;
|
||||
|
||||
/**
|
||||
* @var array A cached queue of adhoc tasks
|
||||
*/
|
||||
@ -236,7 +241,7 @@ class manager {
|
||||
}
|
||||
|
||||
// Check if the task is allowed to be retried or not.
|
||||
$record->attemptsavailable = $task->retry_until_success() ? null : 1;
|
||||
$record->attemptsavailable = $task->retry_until_success() ? self::MAX_RETRY : 1;
|
||||
|
||||
// Check if the same task is already scheduled.
|
||||
if ($checkforexisting && self::task_is_scheduled($task)) {
|
||||
@ -1128,7 +1133,7 @@ class manager {
|
||||
$task->set_pid();
|
||||
$task->set_next_run_time(time() + $delay);
|
||||
$task->set_fail_delay($delay);
|
||||
if (!$task->retry_until_success() && $task->get_attempts_available() > 0) {
|
||||
if ($task->get_attempts_available() > 0) {
|
||||
$task->set_attempts_available($task->get_attempts_available() - 1);
|
||||
}
|
||||
$record = self::record_from_adhoc_task($task);
|
||||
|
@ -164,7 +164,7 @@ class adhoc_task_test extends \advanced_testcase {
|
||||
return: 'attemptsavailable',
|
||||
conditions: ['id' => $taskid1]
|
||||
);
|
||||
$this->assertNull(actual: $attemptsavailable);
|
||||
$this->assertEquals(expected: manager::MAX_RETRY, actual: $attemptsavailable);
|
||||
|
||||
// Get the task from the scheduler, execute it, and mark it as failed.
|
||||
$task = manager::get_next_adhoc_task(timestart: $now);
|
||||
@ -178,7 +178,7 @@ class adhoc_task_test extends \advanced_testcase {
|
||||
return: 'attemptsavailable',
|
||||
conditions: ['id' => $taskid1]
|
||||
);
|
||||
$this->assertNull(actual: $attemptsavailable);
|
||||
$this->assertEquals(expected: manager::MAX_RETRY - 1, actual: $attemptsavailable);
|
||||
|
||||
// Create a no-retry adhoc task.
|
||||
$now = time();
|
||||
|
Loading…
x
Reference in New Issue
Block a user