Skip to content
New issue

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

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

Already on GitHub? # to your account

[5.x] Prevent infinite loops with Laravel Telescope #11390

Open
wants to merge 1 commit into
base: 5.x
Choose a base branch
from

Conversation

duncanmcclean
Copy link
Member

@duncanmcclean duncanmcclean commented Jan 24, 2025

This pull request fixes an issue with Laravel Telescope installed, where an infinite loop would occur if you had entries which link to each other.

Right now, when Telescope encounters an Entry object (whether that be in an event, or in an authorization gate), it'll attempt to serialize it using ->jsonSerialize() which'll return an evaluated array of the augmented entry.

However, if you have an entry which relates back to itself, this evaluated array can cause an infinite loop.

This PR addresses that by returning a shallow augmented array instead, which prevents relationships from being evaluated in the same way, therefore preventing the infinite loop issue.

This fix relies on the formatForTelescope method, added in these Telescope PRs:

Fixes #10782.

@duncanmcclean duncanmcclean marked this pull request as ready for review January 24, 2025 17:49
Copy link
Member

@jasonvarga jasonvarga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did what was explained in the original issue:

  • Added a link field to a collection
  • Entry 1 links to Entry 2
  • Entry 2 links to Entry 3
  • Entry 3 links to Entry 1

The infinite loop still happens when visiting Entry 1 in the CP.

@duncanmcclean
Copy link
Member Author

duncanmcclean commented Feb 6, 2025

Good catch! Looks like I missed adding the hook into Telescope's RequestWatcher (which serializes view data) 🙈

I've opened a PR on the Telescope side to address this: laravel/telescope#1566

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Telescope infinite loop issue
3 participants