perf(data-events): queue dispatches to execute on shutdown #3616
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.
All Submissions:
Changes proposed in this Pull Request:
p1733922470397489-slack-C055SRT7WN4
Depending on the setup, a site can execute 5 dispatches when a reader registers:
membership_status_active
membership_saved
reader_logged_in
reader_registered
network_user_updated
The list grows if the registration happens during a subscription purchase.
Other actions on the site can also dispatch multiple events.
Each dispatch runs a
wp_remote_post()
. Even though it's a non-blocking execution with a timeout of 0.01, calling this function for every dispatch is unnecessary and costs performance.This PR proposes queueing the dispatches to be executed in a single
wp_remote_post()
called on theshutdown
hook. This hook runs right before PHP shuts down execution, including on fatal errors.How to test the changes in this Pull Request:
NEWSPACK_LOG_LEVEL
set to at least2
onwp-config.php
reader_registered
andreader_logged_in
in the same runOther information: