-
Notifications
You must be signed in to change notification settings - Fork 11.2k
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
Event cache used even though event auto discovery is off #28872
Comments
I am facing the same issue. However, the reason why the events are fired twice is not only linked to Basically, this issue uncovers three bad behavior regarding the new event discovery system : 1. Events duplicationOnce the events are cached, every framework/src/Illuminate/Foundation/Support/Providers/EventServiceProvider.php Lines 32 to 34 in f1bb3fe
framework/src/Illuminate/Foundation/Support/Providers/EventServiceProvider.php Lines 63 to 67 in f1bb3fe
Therefore, there will be as may duplicated of every fired events as there is custom EventProviders registered in the app. Example: Once the events are cached: 2. Events cached regardless of shouldDiscoverEventsIn the Obviously, the default This behavior will produce duplication inside the 3. Duplication is possible on the cached events.php fileOverall, it is currently possible to have duplicated listeners in the
|
WorkaroundIf you have multiple EventServiceProviders, and you still want to use the This workaround is not ideal, but it works and maybe it will interest some people. 1. Override the default EventCacheCommandCreate your own implementation of
Note that, I've only added the check on Pay attention that amongst all of your EventProviders, the 2. Override the boot of your custom EventProvidersThe
|
I'll try to propose a PR 🍻 |
Description:
In preparation for adding Event Auto-Discovery to our application, I added the
php events:cache
command to our Envoyer deployment hooks. The PR which added event auto-discovery to our app was however not ready yet, but we still deployed other code, which caused thephp events:cache
command to fire.Following this, every event that was type hinted in our app started to fire twice. Shouldn't the cache not fire at all if
shouldDiscoverEvents
is set tofalse
? Or at least, shouldn't the cache not contain discover events ifshouldDiscoverEvents
is set tofalse
?Steps To Reproduce:
handle
method)php events:cache
shouldDiscoverEvents
is set tofalse
The text was updated successfully, but these errors were encountered: