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

Check implementation instead of assuming it is View #1571

Merged
merged 2 commits into from
Mar 10, 2025

Conversation

AJenbo
Copy link
Contributor

@AJenbo AJenbo commented Mar 9, 2025

Summary

This PR ensures that Laravel Telescope does not crash when handling views that implement Illuminate\Contracts\View\View but are not instances of Illuminate\View\View. Currently, Telescope assumes all views are Illuminate\View\View and calls methods like getPath() and getName() that are not part of the contract, leading to errors in applications with custom view implementations.

Changes

  • Added a check to ensure the view is an instance of Illuminate\View\View before calling getPath() and getName().
  • This prevents Telescope from attempting to call methods that may not exist on valid view implementations, avoiding application crashes.

Future Considerations

While this PR only prevents crashes, a more complete solution could involve:

  • Using name() instead of getName(), as name() is part of the contract.
  • Expanding extractPath() to resolve paths from name() when getPath() is unavailable.
  • Updating Illuminate\Contracts\View\View in Laravel to include getPath() in the future.

This PR does not implement these changes but suggests them as potential improvements for broader compatibility.

@taylorotwell taylorotwell merged commit 4937ee4 into laravel:5.x Mar 10, 2025
16 checks passed
@AJenbo AJenbo deleted the patch-1 branch March 10, 2025 17:17
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