[4.x] Laravel Octane fix: GateWatcher handles stack trace caller not found #1128
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #1072 & #1122
TLDR:
GateWatcher
throws an exception because it can't find the PHP source code location that triggered a gate check for an app using Swoole/Laravel Octane.With
config('telescope.watchers.Watchers\GateWatcher.ignore_packages')
enabled (the default setting), methodgetCallerFromStackTrace()
returnsnull
because only vendor/laravel/* code is traced through and no app/Http/Controllers/*.php file is reached. Middlewarevendor/laravel/framework/src/Illuminate/Auth/Middleware/Authorize.php
triggered the gate check andGateWatcher@recordGateCheck()
throws an exception attempting to save the Telescope entry for a missing file location.telescope/resources/js/screens/gates/preview.vue
Lines 38 to 43 in e31d4e7
The UI hides caller file location details if they're not stored in the Telescope entry so set that path to
null
and prevent this exception.Also fix the
getCallerFromStackTrace()
docblock for@return
as methodQueryWatcher@recordQuery()
already has a conditional for when it returnsnull
.