Skip to content

Commit 9a976d3

Browse files
committed
fix: keep stale job timeout as optional param to avoid breaking change
1 parent 7e40f04 commit 9a976d3

3 files changed

Lines changed: 10 additions & 4 deletions

File tree

Classes/Command/SchedulerCommandController.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,13 @@ public function injectConnection(Connection $connection): void
5454
* Reset stale jobs that have not changed for too long.
5555
*
5656
* @param string $groupName Free jobs in this group only
57+
* @param ?int $minutes @deprecated Use staleJobTimeout configuration setting instead.
5758
*/
5859
public function resetStaleJobsCommand(
5960
string $groupName,
61+
?int $minutes = 10
6062
): void {
61-
$freed = $this->scheduler->resetStaleJobs($groupName);
63+
$freed = $this->scheduler->resetStaleJobs($groupName, $minutes);
6264
if ($freed) {
6365
$this->outputLine('Freed ' . $freed . ' stale jobs.');
6466
}

Classes/Domain/AbstractScheduler.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,15 +283,19 @@ public function activity(ScheduledJob $job): void
283283
* Reset stale jobs that have not changed for too long.
284284
*
285285
* @param string $groupName Free jobs in this group only
286+
* @param int|null $minutes Only free jobs that are stale for at least this many minutes. @deprecated Use staleJobTimeout configuration setting instead.
286287
* @throws Exception
287288
* @return int Number of freed jobs
288289
*/
289-
public function resetStaleJobs(string $groupName): int {
290+
public function resetStaleJobs(
291+
string $groupName,
292+
?int $minutes = null
293+
): int {
290294
return $this->dbal->executeQuery(
291295
sql: static::RESET_STALE_JOBS_QUERY,
292296
params: [
293297
'groupName' => $groupName,
294-
'seconds' => max($this->staleJobTimeoutSecs, 1),
298+
'seconds' => max($minutes === null ? $this->staleJobTimeoutSecs : $minutes * 60, 1),
295299
],
296300
types: [
297301
'groupName' => Types::STRING,

Classes/Domain/Scheduler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function fail(ScheduledJob $job, string $reason): void;
2323

2424
public function activity(ScheduledJob $job): void;
2525

26-
public function resetStaleJobs(string $groupName): int;
26+
public function resetStaleJobs(string $groupName, ?int $minutes = null): int;
2727

2828
public function getConnection(): Connection;
2929

0 commit comments

Comments
 (0)