Skip to content

Fix v2.0.9 regression: Bus::chain breaks with nested closures#129

Draft
JoshSalway wants to merge 1 commit intolaravel:2.xfrom
JoshSalway:fix/serializable-closure-126
Draft

Fix v2.0.9 regression: Bus::chain breaks with nested closures#129
JoshSalway wants to merge 1 commit intolaravel:2.xfrom
JoshSalway:fix/serializable-closure-126

Conversation

@JoshSalway
Copy link

Summary

  • v2.0.9 change to skip objects with __serialize in wrapClosures/mapByReference was too broad
  • Nested closures in array properties (e.g. Bus::chain items inside Bus::batch) were no longer wrapped, causing "Serialization of 'Closure' is not allowed" errors
  • Now skips only Closure-typed properties (which __serialize handles) while recursing into other properties

Note: This is a different fix from PR #1 (method-only attributes). This addresses issue #126 specifically.

Fixes #126

Test plan

  • Run included regression tests (SerializeNestedClosureRegressionTest)
  • Test Bus::chain([fn() => ...]) inside Bus::batch() serialization
  • Verify objects with __serialize and Closure-typed properties still serialize correctly

🤖 Generated with Claude Code

…ialize

The v2.0.9 change to skip objects with __serialize was too broad -
it prevented nested closures (e.g. in array properties) from being
wrapped, causing "Serialization of 'Closure' is not allowed" errors
in patterns like Bus::chain with closures inside Bus::batch.

Instead of skipping the entire object, skip only Closure-typed
properties (which the object's __serialize handles) while still
recursing into other properties to wrap nested closures.

Fixes laravel#126

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link

Thanks for submitting a PR!

Note that draft PRs are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface.

Pull requests that are abandoned in draft may be closed due to inactivity.

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.

v2.0.9 regression: objects with __serialize no longer have nested closures wrapped, causing serialization failure

1 participant