Skip to content

Commit 0f08459

Browse files
authored
[5.x] Fix #1419 (#1424)
* show: check for $batch * retry: check for $batch
1 parent bf3c4a8 commit 0f08459

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

src/Http/Controllers/BatchesController.php

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,14 @@ public function show($id)
5959
{
6060
$batch = $this->batches->find($id);
6161

62-
$failedJobs = app(JobRepository::class)
63-
->getJobs($batch->failedJobIds);
62+
if ($batch) {
63+
$failedJobs = app(JobRepository::class)
64+
->getJobs($batch->failedJobIds);
65+
}
6466

6567
return [
6668
'batch' => $batch,
67-
'failedJobs' => $failedJobs,
69+
'failedJobs' => $failedJobs ?? null,
6870
];
6971
}
7072

@@ -78,14 +80,16 @@ public function retry($id)
7880
{
7981
$batch = $this->batches->find($id);
8082

81-
app(JobRepository::class)
82-
->getJobs($batch->failedJobIds)
83-
->reject(function ($job) {
84-
$payload = json_decode($job->payload);
83+
if ($batch) {
84+
app(JobRepository::class)
85+
->getJobs($batch->failedJobIds)
86+
->reject(function ($job) {
87+
$payload = json_decode($job->payload);
8588

86-
return isset($payload->retry_of);
87-
})->each(function ($job) {
88-
dispatch(new RetryFailedJob($job->id));
89-
});
89+
return isset($payload->retry_of);
90+
})->each(function ($job) {
91+
dispatch(new RetryFailedJob($job->id));
92+
});
93+
}
9094
}
9195
}

0 commit comments

Comments
 (0)