diff --git a/src/Illuminate/Queue/Console/RetryCommand.php b/src/Illuminate/Queue/Console/RetryCommand.php index e9120a976962..055790da6446 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,25 @@ 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']); + + if (method_exists($jobInstance, 'retryUntil')) { + $newRetryUntil = $jobInstance->retryUntil()->timestamp; + + $payload['retryUntil'] = $newRetryUntil; + } + + return json_encode($payload); + } }