Skip to content

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

Closed
JoshSalway wants to merge 1 commit into2.xfrom
fix/serializable-closure-126
Closed

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

Conversation

@JoshSalway
Copy link
Owner

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 laravel#126 specifically.

Fixes laravel#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>
@JoshSalway
Copy link
Owner Author

Moved upstream → laravel#129

@JoshSalway JoshSalway closed this Mar 22, 2026
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