From 0f084596856d2fcdedccd3ebfe25776e248041ab Mon Sep 17 00:00:00 2001 From: Troy Mayrand <61019450+tmayrand@users.noreply.github.com> Date: Thu, 25 Apr 2024 10:20:44 -0400 Subject: [PATCH] [5.x] Fix #1419 (#1424) * show: check for $batch * retry: check for $batch --- src/Http/Controllers/BatchesController.php | 26 +++++++++++++--------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/Http/Controllers/BatchesController.php b/src/Http/Controllers/BatchesController.php index 53e88ae3..3f092928 100644 --- a/src/Http/Controllers/BatchesController.php +++ b/src/Http/Controllers/BatchesController.php @@ -59,12 +59,14 @@ public function show($id) { $batch = $this->batches->find($id); - $failedJobs = app(JobRepository::class) - ->getJobs($batch->failedJobIds); + if ($batch) { + $failedJobs = app(JobRepository::class) + ->getJobs($batch->failedJobIds); + } return [ 'batch' => $batch, - 'failedJobs' => $failedJobs, + 'failedJobs' => $failedJobs ?? null, ]; } @@ -78,14 +80,16 @@ public function retry($id) { $batch = $this->batches->find($id); - app(JobRepository::class) - ->getJobs($batch->failedJobIds) - ->reject(function ($job) { - $payload = json_decode($job->payload); + if ($batch) { + app(JobRepository::class) + ->getJobs($batch->failedJobIds) + ->reject(function ($job) { + $payload = json_decode($job->payload); - return isset($payload->retry_of); - })->each(function ($job) { - dispatch(new RetryFailedJob($job->id)); - }); + return isset($payload->retry_of); + })->each(function ($job) { + dispatch(new RetryFailedJob($job->id)); + }); + } } }