Skip to content

Commit

Permalink
Added check not to retry non-existing jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
lasselehtinen committed Mar 9, 2017
1 parent f1de6e9 commit 1010175
Showing 1 changed file with 24 additions and 14 deletions.
38 changes: 24 additions & 14 deletions src/Illuminate/Queue/Console/RetryCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}

Expand All @@ -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
);
}

Expand Down

0 comments on commit 1010175

Please sign in to comment.