From 72596ae3612bb6dfa21468f8d7d77f6cc545890d Mon Sep 17 00:00:00 2001 From: Kevin Ullyott Date: Mon, 4 Jan 2021 22:13:36 -0500 Subject: [PATCH 1/3] Refresh the retryUntil timer on job retry Signed-off-by: Kevin Ullyott --- src/Illuminate/Queue/Console/RetryCommand.php | 36 ++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/src/Illuminate/Queue/Console/RetryCommand.php b/src/Illuminate/Queue/Console/RetryCommand.php index e9120a976962..28491debd2e9 100644 --- a/src/Illuminate/Queue/Console/RetryCommand.php +++ b/src/Illuminate/Queue/Console/RetryCommand.php @@ -93,10 +93,25 @@ protected function getJobIdsByRanges(array $ranges) protected function retryJob($job) { $this->laravel['queue']->connection($job->connection)->pushRaw( - $this->resetAttempts($job->payload), $job->queue + $this->retryRefresh($job->payload), $job->queue ); } + /** + * Possibly refresh job attempts and retryUntil value + * + * @param string $payload + * @return string + */ + protected function retryRefresh($payload) + { + $payload = $this->resetAttempts($payload); + + $payload = $this->refreshRetryUntil($payload); + + return $payload; + } + /** * Reset the payload attempts. * @@ -115,4 +130,23 @@ protected function resetAttempts($payload) return json_encode($payload); } + + /** + * Refreshes a jobs retryUntil time with it's own retryUntil method + * + * @param string $payload + * @return string + */ + protected function refreshRetryUntil($payload) + { + $payload = json_decode($payload, true); + + $jobInstance = unserialize($payload['data']['command']); + + $newRetryUntil = $jobInstance->retryUntil()->timestamp; + + $payload['retryUntil'] = $newRetryUntil; + + return json_encode($payload); + } } From d91253be99029a27caa225caa47bf80645a0c21e Mon Sep 17 00:00:00 2001 From: Kevin Ullyott Date: Mon, 4 Jan 2021 22:26:28 -0500 Subject: [PATCH 2/3] Check if the job has a retryUntil method Signed-off-by: Kevin Ullyott --- src/Illuminate/Queue/Console/RetryCommand.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/Queue/Console/RetryCommand.php b/src/Illuminate/Queue/Console/RetryCommand.php index 28491debd2e9..e5c4dc0af03a 100644 --- a/src/Illuminate/Queue/Console/RetryCommand.php +++ b/src/Illuminate/Queue/Console/RetryCommand.php @@ -143,9 +143,11 @@ protected function refreshRetryUntil($payload) $jobInstance = unserialize($payload['data']['command']); - $newRetryUntil = $jobInstance->retryUntil()->timestamp; + if (method_exists($jobInstance, 'retryUntil')) { + $newRetryUntil = $jobInstance->retryUntil()->timestamp; - $payload['retryUntil'] = $newRetryUntil; + $payload['retryUntil'] = $newRetryUntil; + } return json_encode($payload); } From cdcc60bad460348f72b07501aa0010673b27727f Mon Sep 17 00:00:00 2001 From: Kevin Ullyott Date: Mon, 4 Jan 2021 22:43:41 -0500 Subject: [PATCH 3/3] Proper punctuation Signed-off-by: Kevin Ullyott --- src/Illuminate/Queue/Console/RetryCommand.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/Queue/Console/RetryCommand.php b/src/Illuminate/Queue/Console/RetryCommand.php index e5c4dc0af03a..055790da6446 100644 --- a/src/Illuminate/Queue/Console/RetryCommand.php +++ b/src/Illuminate/Queue/Console/RetryCommand.php @@ -98,7 +98,7 @@ protected function retryJob($job) } /** - * Possibly refresh job attempts and retryUntil value + * Possibly refresh job attempts and retryUntil value. * * @param string $payload * @return string @@ -132,7 +132,7 @@ protected function resetAttempts($payload) } /** - * Refreshes a jobs retryUntil time with it's own retryUntil method + * Refreshes a jobs retryUntil time with it's own retryUntil method. * * @param string $payload * @return string