diff --git a/src/Illuminate/Queue/Console/RetryCommand.php b/src/Illuminate/Queue/Console/RetryCommand.php index 6246ddfc0973..0090f3ff68ee 100644 --- a/src/Illuminate/Queue/Console/RetryCommand.php +++ b/src/Illuminate/Queue/Console/RetryCommand.php @@ -30,11 +30,17 @@ class RetryCommand extends Command public function fire() { foreach ($this->getJobIds() as $id) { - $this->retryJob($id); + $job = $this->getJob($id); - $this->info("The failed job [{$id}] has been pushed back onto the queue!"); + if (is_null($job)) { + $this->error("No failed job matches the given ID [{$id}]."); + } else { + $this->retryJob($job); - $this->laravel['queue.failer']->forget($id); + $this->info("The failed job [{$id}] has been pushed back onto the queue!"); + + $this->laravel['queue.failer']->forget($id); + } } } @@ -55,21 +61,25 @@ protected function getJobIds() } /** - * Retry the queue job with the given ID. - * + * Get the job instance. * @param string $id - * @return void + * @return stdClass */ - protected function retryJob($id) + protected function getJob($id) { - if (is_null($failed = $this->laravel['queue.failer']->find($id))) { - return $this->error("No failed job matches the given ID [{$id}]."); - } - - $failed = (object) $failed; + return $this->laravel['queue.failer']->find($id); + } - $this->laravel['queue']->connection($failed->connection)->pushRaw( - $this->resetAttempts($failed->payload), $failed->queue + /** + * Retry the queue job. + * + * @param stdClass $job + * @return void + */ + protected function retryJob($job) + { + $this->laravel['queue']->connection($job->connection)->pushRaw( + $this->resetAttempts($job->payload), $job->queue ); }