From c370b278f7a417bbc002a00891a897aec3f71747 Mon Sep 17 00:00:00 2001 From: Loz Calver Date: Tue, 31 May 2022 09:32:34 +0100 Subject: [PATCH] FIX: Correctly log errors during job initialisation (fixes #316) --- src/Services/QueuedJobService.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Services/QueuedJobService.php b/src/Services/QueuedJobService.php index 0093cdc1..117f69a1 100644 --- a/src/Services/QueuedJobService.php +++ b/src/Services/QueuedJobService.php @@ -992,7 +992,17 @@ public function runJob($jobId) $this->extend('updateJobDescriptorAndJobOnCompletion', $jobDescriptor, $job); } } catch (\Throwable $e) { - // PHP 7 Error handling) + // If the job failed initialisation $job will be null, so attempt to instantiate it here + if ($job === null) { + try { + $impl = $jobDescriptor->Implementation; + /** @var QueuedJob $job */ + $job = Injector::inst()->create($impl); + } catch (\Throwable $e) { + // No-op + } + } + $this->handleBrokenJobException($jobDescriptor, $job, $e); $broken = true; }