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

Ensure we are on a multisite before using switch_to_blog #780

Merged
merged 1 commit into from
Jul 20, 2021

Conversation

dkotter
Copy link
Collaborator

@dkotter dkotter commented Jul 15, 2021

Description of the Change

As detailed in #773, if you use Distributor on a multisite and then convert some of those sites into single install sites, you can run into PHP fatal errors. The issue here is around our usage of switch_to_blog. We had checks in place to ensure we only used that if the proper Distributor meta was in place but in the above scenario, you can have that meta but actually not be on a multisite.

This PR fixes that by adding is_multisite() checks to any function that uses switch_to_blog after checking for the existence of Distributor meta. This should prevent fatal errors from occurring in the above detailed scenario.

Alternate Designs

None

Benefits

No PHP fatal errors will happen when using Distributor on sites that used to be part of a multisite

Possible Drawbacks

None

Verification Process

  1. Create a WordPress multisite with two sites
  2. Distribute some content from site A to site B
  3. Convert site B to a stand-alone site
  4. Edit one of the items that was distributed and see that no errors occur

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

#773

Changelog Entry

Fixed - ensure we are on a multisite before using switch_to_blog

…we also check that we are on a multisite to avoid errors in the case of a site that used to be a multisite but is no longer
@dkotter dkotter self-assigned this Jul 15, 2021
@jeffpaul jeffpaul added this to the 1.6.5 milestone Jul 15, 2021
@jeffpaul jeffpaul requested a review from dinhtungdu July 15, 2021 20:55
Copy link
Contributor

@helen helen left a comment

Choose a reason for hiding this comment

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

LGTM

@helen helen merged commit 4e07136 into develop Jul 20, 2021
@helen helen deleted the fix/ensure-multisite branch July 20, 2021 22:14
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.

3 participants