#33816 closed defect (bug) (fixed)
Rewrite rules may be flushed incorrectly when home, siteurl, or page_on_front is updated in multisite
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 4.4 | Priority: | normal |
| Severity: | normal | Version: | 3.0 |
| Component: | Rewrite Rules | Keywords: | has-patch |
| Focuses: | multisite | Cc: |
Description
Rewrite rules have been flushed when the home url for a site is updated for a very long time. See [2494].
Now, if the siteurl, home, or page_on_front options are updated, update_home_siteurl() fires and flushes rewrite rules.
If this happens in site-info.php while updating a site's options in a switched state, the rewrite rules are deleted and then regenerated in the context of the current network's main site. Further up in site-info.php, we already use delete_option( 'rewrite_rules' ); directly as we know that is a better way to flush rules in a switched context.
I think the best option here is to add an ms_is_switched() check to update_home_siteurl() and just delete the rewrite_rules option when true rather than flush. I haven't fully tested this yet though.
Attachments (2)
Change History (7)
#2
@
10 years ago
We could also add a multisite/switched check to flush_rewrite_rules() itself as this is a pretty common error in general.
#3
@
10 years ago
- Milestone changed from Future Release to 4.4
33816.2.diff targets the specific issue and leaves flush_rewrite_rules() as is for now.
A better description of what happens here:
- A staging site is setup, plugins are activated, and content is entered at
https://stage.foo.bar/. - A custom post type is added by a plugin so that the URL
https://stage.foo.bar/my-content-type/is valid. - The staging site URL is updated in the network admin to
https://foo.bar/. https://foo.bar/my-content-type/is now a 404 because the rewrite rules were generated in the context of the network's main site.
Deleting the rewrite_rules option rather than flushing rewrite rules in this scenario will result in proper rewrite rules being generated on that site's next page view.
33816.diff adds the
ms_is_switched()check. We may also be able to remove the existingdelete_option( 'rewrite_rules' );insite-info.php.