You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PR #25261 started passing the guard to some Authentication events as a constructor parameter.
Passing the whole guard breaks any queued listeners as the Guards in general relies on closures (SessionGuard for instance have the request, user provider and event dispatcher as properties, each of them have closure-based resolvers).
I have a queued listener that updates a timestamp in the user's record whenever the Login event is fired. Use it in every project (show a last logged at timestamp).
To migrate some of them to Laravel 5.7 I had to make this listener synchronous (remove the ShouldQueue interface) as with the change #25261 PR introduces an Serialization of 'Closure' is not allowed exception is thrown when the listener is queued.
I have some suggestions:
Revert to the old behavior
Pass only the guard name to the event, as it was originally intended in that PR
Document it as a breaking change in the upgrade guide, something like: If you are listening for Authentication Events you should not use queued listeners anymore...
I can submit a PR for any of these alternatives as soon as we have a decision
Steps To Reproduce:
1, Create a new app:
$ laravel new test-app
$ cd test-app
$ php artisan make:auth
$ php artisan make:listener TestListener --queued --event=Illuminate\\Auth\\Events\\Login
$ # change the .env with database settings
$ php artisan migrate
Register the listener on the EventServiceProvider:
Description:
PR #25261 started passing the guard to some Authentication events as a constructor parameter.
Passing the whole guard breaks any queued listeners as the Guards in general relies on closures (
SessionGuard
for instance have the request, user provider and event dispatcher as properties, each of them have closure-based resolvers).I have a queued listener that updates a timestamp in the user's record whenever the
Login
event is fired. Use it in every project (show a last logged at timestamp).To migrate some of them to Laravel 5.7 I had to make this listener synchronous (remove the
ShouldQueue
interface) as with the change #25261 PR introduces anSerialization of 'Closure' is not allowed
exception is thrown when the listener is queued.I have some suggestions:
If you are listening for Authentication Events you should not use queued listeners anymore...
I can submit a PR for any of these alternatives as soon as we have a decision
Steps To Reproduce:
1, Create a new app:
EventServiceProvider
:As after user registration the
Login
event is fired it throws an exception at this point.The text was updated successfully, but these errors were encountered: