Skip to content

Commit

Permalink
GateWatcher handles stack trace caller not found (#1128)
Browse files Browse the repository at this point in the history
For an app using Swoole/Laravel Octane and Telescope configured for
`config('telescope.ignore_packages') === true`, method
getCallerFromStackTrace() will return null.

UI file telescope/resources/js/screens/gates/preview.vue will hide
caller file location details if they're not stored in the Telescope
entry so save that path as null.

Also fix the getCallerFromStackTrace() @return docblock as that method
was written before Laravel Octane magic was conjured up.
  • Loading branch information
derekmd authored Sep 16, 2021
1 parent 9fba33f commit cdc65f1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Watchers/FetchesStackTrace.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ trait FetchesStackTrace
* Find the first frame in the stack trace outside of Telescope/Laravel.
*
* @param string|array $forgetLines
* @return array
* @return array|null
*/
protected function getCallerFromStackTrace($forgetLines = 0)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Watchers/GateWatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ public function recordGateCheck(?Authenticatable $user, $ability, $result, $argu
'ability' => $ability,
'result' => $this->gateResult($result),
'arguments' => $this->formatArguments($arguments),
'file' => $caller['file'],
'line' => $caller['line'],
'file' => $caller['file'] ?? null,
'line' => $caller['line'] ?? null,
]));

return $result;
Expand Down

0 comments on commit cdc65f1

Please sign in to comment.