Skip to content
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

Reset the last_changed_sites option when a new site is created #716

Merged
merged 1 commit into from
Mar 4, 2021

Conversation

dkotter
Copy link
Collaborator

@dkotter dkotter commented Feb 10, 2021

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 to clean_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:

  • I have read the CONTRIBUTING document.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests passed.

Applicable Issues

#639

@dkotter dkotter linked an issue Feb 10, 2021 that may be closed by this pull request
@dkotter dkotter self-assigned this Feb 10, 2021
@jeffpaul jeffpaul added this to the 1.6.3 milestone Feb 10, 2021
@jeffpaul jeffpaul requested a review from dinhtungdu February 10, 2021 19:46
Copy link
Contributor

@dinhtungdu dinhtungdu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍🏼

@jeffpaul jeffpaul merged commit 0060b4b into develop Mar 4, 2021
@jeffpaul jeffpaul deleted the fix/insert-site-cache-clear branch March 4, 2021 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Doesn't initialize properly on sites created with WP CLI
3 participants