Reset the last_changed_sites
option when a new site is created
#716
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.
Description of the Change
We currently have some caching around our internal sites list that should be updated anytime a new site is created. An issue was reported where if a site was created using WP-CLI, no connections would show until that site was manually saved in the network settings. This seems to point to a caching issue.
Looking through the code that fires when a new site is created via WP-CLI, there is a possibility that the current way we update our cache may not fire correctly, under certain circumstances.
This PR adds a new hook onto
wp_insert_site
that fires our same cache clearing function we currently use that is hooked toclean_site_cache
. In theory, this second hook should always fire, while the first one may not fire in certain circumstances. For most circumstances though, both of these hooks will probably end up firing.Alternate Designs
None
Benefits
The internal connections list should be more accurate now when a new site is created
Possible Drawbacks
For most setups, I think we'll end up with both hooks firing, which isn't a huge deal but we'll basically clear the cache twice.
Verification Process
Within an existing multisite, create a new site, go to that site and go to the Pull screen. Ensure connections show on that screen. Run this test both with manually creating a site and using WP-CLI.
Can also test from the perspective of an existing site. So create a new site, go to an existing site, go to the Pull screen and ensure the newly created site shows in the list.
Checklist:
Applicable Issues
#639