Skip to content

Commit

Permalink
Run prepareNestedBatches on append/prependToChain & chain (#52486)
Browse files Browse the repository at this point in the history
* Run prepareNestedBatches on append/prependToChain

* Cleanup leftover import

* Update chain method

* Update Queueable.php

---------

Co-authored-by: Taylor Otwell <[email protected]>
  • Loading branch information
SabatinoMasala and taylorotwell authored Aug 15, 2024
1 parent 85165d7 commit 0b3d2aa
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/Illuminate/Bus/Queueable.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,9 @@ public function through($middleware)
*/
public function chain($chain)
{
$this->chained = collect($chain)->map(function ($job) {
$jobs = ChainedBatch::prepareNestedBatches(collect($chain));

$this->chained = $jobs->map(function ($job) {
return $this->serializeJob($job);
})->all();

Expand All @@ -212,7 +214,9 @@ public function chain($chain)
*/
public function prependToChain($job)
{
$this->chained = Arr::prepend($this->chained, $this->serializeJob($job));
$jobs = ChainedBatch::prepareNestedBatches(collect([$job]));

$this->chained = Arr::prepend($this->chained, $this->serializeJob($jobs->first()));

return $this;
}
Expand All @@ -225,7 +229,9 @@ public function prependToChain($job)
*/
public function appendToChain($job)
{
$this->chained = array_merge($this->chained, [$this->serializeJob($job)]);
$jobs = ChainedBatch::prepareNestedBatches(collect([$job]));

$this->chained = array_merge($this->chained, [$this->serializeJob($jobs->first())]);

return $this;
}
Expand Down

0 comments on commit 0b3d2aa

Please sign in to comment.