8000 Set the job instance when creating a new instance of command after fa… · laravel/framework@6fffe41 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6fffe41

Browse files
committed
Set the job instance when creating a new instance of command after failure
1 parent 3620c42 commit 6fffe41

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/Illuminate/Queue/CallQueuedHandler.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,10 +276,14 @@ protected function ensureUniqueJobLockIsReleasedViaContext()
276276
* @param string $uuid
277277
* @return void
278278
*/
279-
public function failed(array $data, $e, string $uuid)
279+
public function failed(array $data, $e, string $uuid, Job|null $job = null)
280280
{
281281
$command = $this->getCommand($data);
282282

283+
if (! is_null($job)) {
284+
$command = $this->setJobInstanceIfNecessary($job, $command);
285+
}
286+
283287
if (! $command instanceof ShouldBeUniqueUntilProcessing) {
284288
$this->ensureUniqueJobLockIsReleased($command);
285289
}

src/Illuminate/Queue/Jobs/Job.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ protected function failed($e)
251251
[$class, $method] = JobName::parse($payload['job']);
252252

253253
if (method_exists($this->instance = $this->resolve($class), 'failed')) {
254-
$this->instance->failed($payload['data'], $e, $payload['uuid'] ?? '');
254+
$this->instance->failed($payload['data'], $e, $payload['uuid'] ?? '', $this);
255255
}
256256
}
257257

0 commit comments

Comments
 (0)
0