Skip to content

Commit 0b3d2aa

Browse files
Run prepareNestedBatches on append/prependToChain & chain (#52486)
* Run prepareNestedBatches on append/prependToChain * Cleanup leftover import * Update chain method * Update Queueable.php --------- Co-authored-by: Taylor Otwell <taylor@laravel.com>
1 parent 85165d7 commit 0b3d2aa

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/Illuminate/Bus/Queueable.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,9 @@ public function through($middleware)
197197
*/
198198
public function chain($chain)
199199
{
200-
$this->chained = collect($chain)->map(function ($job) {
200+
$jobs = ChainedBatch::prepareNestedBatches(collect($chain));
201+
202+
$this->chained = $jobs->map(function ($job) {
201203
return $this->serializeJob($job);
202204
})->all();
203205

@@ -212,7 +214,9 @@ public function chain($chain)
212214
*/
213215
public function prependToChain($job)
214216
{
215-
$this->chained = Arr::prepend($this->chained, $this->serializeJob($job));
217+
$jobs = ChainedBatch::prepareNestedBatches(collect([$job]));
218+
219+
$this->chained = Arr::prepend($this->chained, $this->serializeJob($jobs->first()));
216220

217221
return $this;
218222
}
@@ -225,7 +229,9 @@ public function prependToChain($job)
225229
*/
226230
public function appendToChain($job)
227231
{
228-
$this->chained = array_merge($this->chained, [$this->serializeJob($job)]);
232+
$jobs = ChainedBatch::prepareNestedBatches(collect([$job]));
233+
234+
$this->chained = array_merge($this->chained, [$this->serializeJob($jobs->first())]);
229235

230236
return $this;
231237
}

0 commit comments

Comments
 (0)