Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.x] Ability to override how objects are serialized #1562

Merged
merged 3 commits into from
Jan 24, 2025

Conversation

duncanmcclean
Copy link
Contributor

@duncanmcclean duncanmcclean commented Jan 24, 2025

This pull request introduces a formatForTelescope method, allowing developers to override how Telescope formats/serializes their objects.

By default, Telescope uses json_decode(json_encode($object), true) to format/serialize objects, which takes the object's properties and attempts to JSON serialize them.

However, in our case, where ->jsonSerialize() may return objects which reference the current object, that isn't ideal as it causes an infinite loop.

Instead, we'd like to take control of the serialization logic and return an array without any of the "circular relationships".

Related: statamic/cms#10782

@duncanmcclean duncanmcclean changed the title Allow overriding how objects get serialized Ability to override how objects are serialized Jan 24, 2025
@duncanmcclean duncanmcclean changed the title Ability to override how objects are serialized [5.x] Ability to override how objects are serialized Jan 24, 2025
@taylorotwell taylorotwell merged commit bc3df85 into laravel:5.x Jan 24, 2025
13 checks passed
@duncanmcclean duncanmcclean deleted the format-for-telescope branch January 24, 2025 17:19
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