[5.8] Prevent event cache from firing multiple times the same event(s) #28904
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.
This is a proposed solution for solving #28872 .
Changes explanations:
EventCacheCommand
discoverEvents
are cached only whenshouldDiscoverEvents
is true on the related providers, otherwise only thelistens
are cached.events.php
so the the events/Listeners are grouped by EventServiceProvider.instead of the old structure :
array_merge
toarray_merge_recursive
because it still is technically possible that a basiclisten
event is also inside a discovered event.EventServiceProvider
boot
methods now calls agetEvents
to get the events of both discover and listengetEvents
will return ONLY the events located under the name of the current EventServiceProvider in theevents.php
cache.Indeed, the $this->listens() are already cached and they are all located inside the cache file, so there is no need to merge the cache file with listens;
There is also no need to check for
shouldDiscoverEvents
because it was already done inside theevent:cache
command.I hope this helps, cheers !