Skip to content

[12.x] Add dispatchBatchInChain() to Queueable trait#58916

Open
heffaklump90 wants to merge 2 commits intolaravel:12.xfrom
heffaklump90:dispatch-batch-in-chain
Open

[12.x] Add dispatchBatchInChain() to Queueable trait#58916
heffaklump90 wants to merge 2 commits intolaravel:12.xfrom
heffaklump90:dispatch-batch-in-chain

Conversation

@heffaklump90
Copy link

Summary

  • Adds dispatchBatchInChain(PendingBatch $batch) method to the Queueable trait, allowing any job (including closure jobs) to dispatch a batch as part of the current job chain
  • Simplifies ChainedBatch to delegate to this new method instead of duplicating the logic
  • Removes ChainedBatch::attachRemainderOfChainToEndOfBatch() (now handled by the trait method)

Motivation

As suggested by @dxnter in PR #58905, this approach is simpler than a dedicated DeferredBatch class. Any job can now call $this->dispatchBatchInChain($batch) to hand off chain continuation to a batch at runtime — no new class needed.

Test plan

  • Added 7 new tests in BusDispatchBatchInChainTest covering: batch dispatch with chain clearing, cancelled batch handling, catch callback propagation, empty chain, chain metadata propagation, and CallQueuedClosure compatibility
  • Existing BusBatchTest passes unchanged (behavior is identical)

🤖 Generated with Claude Code

heffaklump90 and others added 2 commits February 19, 2026 08:47
Move batch-in-chain dispatch logic from ChainedBatch into the Queueable
trait so any job (including closure jobs) can hand off chain continuation
to a batch at runtime. ChainedBatch now delegates to this method instead
of having its own copy of the logic.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments