Skip to content

Commit

Permalink
Remove duplicate queries to find batch (#41121)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sébastien Nikolaou authored Feb 21, 2022
1 parent 8346d07 commit 502a505
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/Illuminate/Queue/CallQueuedHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,13 @@ protected function ensureSuccessfulBatchJobIsRecorded($command)
$uses = class_uses_recursive($command);

if (! in_array(Batchable::class, $uses) ||
! in_array(InteractsWithQueue::class, $uses) ||
is_null($command->batch())) {
! in_array(InteractsWithQueue::class, $uses)) {
return;
}

$command->batch()->recordSuccessfulJob($command->job->uuid());
if ($batch = $command->batch()) {
$batch->recordSuccessfulJob($command->job->uuid());
}
}

/**
Expand Down Expand Up @@ -273,12 +274,13 @@ public function failed(array $data, $e, string $uuid)
*/
protected function ensureFailedBatchJobIsRecorded(string $uuid, $command, $e)
{
if (! in_array(Batchable::class, class_uses_recursive($command)) ||
is_null($command->batch())) {
if (! in_array(Batchable::class, class_uses_recursive($command))) {
return;
}

$command->batch()->recordFailedJob($uuid, $e);
if ($batch = $command->batch()) {
$batch->recordFailedJob($uuid, $e);
}
}

/**
Expand Down

0 comments on commit 502a505

Please sign in to comment.