Skip to content

[13.x] Fix batch finally callbacks after then deletes batch - #61226

Closed
Button99 wants to merge 1 commit into
laravel:13.xfrom
Button99:13.x
Closed

Button99 wants to merge 1 commit into
laravel:13.xfrom
Button99:13.x

Conversation

@Button99

Copy link
Copy Markdown
Contributor

This PR fixes a TypeError that can occur when a batch then() callback deletes the batch and a finally() callback is also registered.

Batch::invokeCallbacks() previously assumed $this->fresh() always returned a Batch instance. If the then() callback deleted the persisted batch row, the later finally() callback received null, violating invokeHandlerCallback()'s non-nullable Batch parameter.

This now falls back to the current in-memory batch instance when fresh() returns null.

@taylorotwell

Copy link
Copy Markdown
Member

Honestly the code should probably just bail if the batch record has been deleted?

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.

2 participants