core
core copied to clipboard
Call to a member function hasPermissionTo() on null
Apiato Core Version
8.7.0
PHP Version
8.2
Database Driver & Version
No response
Description
https://github.com/apiato/core/blob/149282fbd6bfe54dfefc6e14d8142834b9612fab/Abstracts/Requests/Request.php?plain=1#L128-L140
This method triggers a "Call to a member function hasPermissionTo() on null" error if the middleware is removed from the Route, for example.
And if there is any value in the Permissions block in the Request.
I think the solution would be to check for the existence of $user in the closure before passing it to the anonymous function.
https://github.com/apiato/core/blob/149282fbd6bfe54dfefc6e14d8142834b9612fab/Abstracts/Requests/Request.php?plain=2#L137-L139
Steps To Reproduce
- Set values for checking in the Permissions block in the Request.
- Remove the middleware method from the Route if it exists.
- Pass this Request to a WebController.
- Make a request to this Route.