WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 8 months ago

#16201 closed defect (bug) (invalid)

when updating a multisite blog subblogs getting 404 error

Reported by: YogieAnamCara Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.0
Component: Multisite Keywords: needs-patch
Focuses: Cc:

Description

When I run an update at my multisite, I get 404 error when I try to view a post. This error resolves when I change or update the permalinks at each sub blog. But it is annoying to do so when you have hundreds of sub blogs.

Attachments (1)

ms-functions-patch-r23470.diff (703 bytes) - added by mackensen 14 months ago.

Download all attachments as: .zip

Change History (31)

comment:1 YogieAnamCara3 years ago

  • Component changed from General to Multisite

comment:2 follow-up: garyc403 years ago

You were upgrading from which version to which? 3.0.3 to 3.0.4?

Also, what's the current permalink scheme you're using?

comment:3 garyc403 years ago

  • Keywords reporter-feedback added; multisite permalink 404 error removed

comment:5 nacin3 years ago

I commented to the forum thread. Those rewrite rules look *very* weird.

I think I've seen this before in MU, but I was just never able to reproduce it. It also didn't just happen on upgrade, but that's another story. I ended up just dropping some code in the 404 handler to check if the rewrite rules were corrupted (obvious by the missing /blog/) and set a locking transient then flush the rewrite rules if so.

comment:6 yogieanamcara3 years ago

yes the bug is on the forum http://wordpress.org/support/topic/404-errors-after-update-need-to-flush-rewrite-rules-network-wide
I have posted several more information there...

comment:7 in reply to: ↑ 2 ; follow-up: yogieanamcara3 years ago

Replying to garyc40:

You were upgrading from which version to which? 3.0.3 to 3.0.4?

Also, what's the current permalink scheme you're using?

It is not a major or core update, it is just when updating themes or plugins at the root and deploy these into the sub blogs

comment:8 follow-up: SergeyBiryukov3 years ago

To summarize:

Looks like main blog structure is applied to a sub-blog under some circumstances.

comment:9 in reply to: ↑ 7 ; follow-up: SergeyBiryukov3 years ago

Replying to yogieanamcara:

It is not a major or core update, it is just when updating themes or plugins at the root and deploy these into the sub blogs

What exactly do you mean by deploying?

comment:10 in reply to: ↑ 9 yogieanamcara3 years ago

Replying to SergeyBiryukov:

Replying to yogieanamcara:

It is not a major or core update, it is just when updating themes or plugins at the root and deploy these into the sub blogs

What exactly do you mean by deploying?

I was talkin about the
-> Super Admin -> Update
function at the root.

Version 0, edited 3 years ago by yogieanamcara (next)

comment:11 in reply to: ↑ 8 ; follow-up: yogieanamcara3 years ago

Replying to SergeyBiryukov:

To summarize:

Looks like main blog structure is applied to a sub-blog under some circumstances.

Yes, but in regards to your last sentence, even when the main blog has the same permalink structure as it's sub blogs, the sub blogs reporting the 404 errors!

comment:12 in reply to: ↑ 11 SergeyBiryukov3 years ago

Replying to yogieanamcara:

Yes, but in regards to your last sentence, even when the main blog has the same permalink structure as it's sub blogs, the sub blogs reporting the 404 errors!

I guess that's because of the blog/ prefix on the main blog.

comment:13 yogieanamcara3 years ago

With the latest update to WP 3.0.5 this issue seems to be solved to me. I do not get any 404 errors after updating (/wp-admin/ms-upgrade-network.php) or updating plugins & themes.

Update: Sorry the bug is still there :(

Last edited 3 years ago by yogieanamcara (previous) (diff)

comment:14 yogieanamcara3 years ago

With WP 3.1 it is still the same here, after doing a network upgrade to all my sub blogs I have to manually go to all sub blogs and open the permalink dialog and click on the save button do get rid of the 404 errors.

comment:15 follow-up: arnonel3 years ago

Has this been resolved yet? I have so many blogs in my multi site and updating every single ones permalinks is starting to drive me nuts

Please could you look into this urgently?

comment:16 arnonel3 years ago

  • Cc arnonel added
  • Severity changed from major to critical

comment:17 in reply to: ↑ 15 SergeyBiryukov3 years ago

Replying to arnonel:

Has this been resolved yet?

I took another look at this and still not sure how to reproduce the scenario when a main blog structure is applied to sub-blogs on network upgrade. My guess it that some plugin is doing something wrong (like calling $wp_rewrite->flush_rules() out of place).

YogieAnamCara wrote that he's using sub-directory install with the Domain Mapping Plugin. Is this the case for you too?

Can you reproduce it on a clean install?

comment:18 mariusmandal3 years ago

  • Cc mariusmandal added

I've been experiencing the same bug in a clean install WP 3.2.1

My sites have been created using the create_empty blog() running in loop. For some reason, the rewrite rules of subpages contain the same structure as the main blog (starting with blog/). After applying a bug-fix, the problem is, at least so far, gone for good.

I've used several tricks, all of which fixes the bug:

  • updating permalink settings of all subpages
  • manually modified the rewrite_rules in the database (get_option, serialize, str_replace removing 'blog/', unserialize, update option)
  • running the script at http://pastie.org/1485455 (and adding the line $wp_rewrites->init(); before flushing

For me it seems that the problem might be within using the create_empty_blog (in a loop).
It might have something to do with the bug (and/or fix) of loop-creating, ref: Ticket #12028

Hope this could help someone finding the bug, and please tell if I could help in any way! That said I'm a WP-noob, but love to help ;)

comment:19 Ipstenu23 months ago

  • Cc ipstenu@… added

comment:20 Mamaduka23 months ago

  • Cc georgemamadashvili@… added

comment:21 mgyura20 months ago

  • Cc mgyura added

Any luck with this? For me the issue seems to happen consistently after updating the plugin
"Events Manager"

The plugins on my MultiSite install that call $wp_rewrite->flush_rules(); are:

Events Manager, Gravity Forms Directory & Addon, and WordPress SEO

Please let me know if I can help in any way.

Last edited 20 months ago by mgyura (previous) (diff)

comment:22 follow-up: wpmuguru18 months ago

  • Severity changed from critical to normal

Can anyone reproduce this in an install with no plugins and sites that are created with the Network Admin -> Add Site screen ?

comment:23 in reply to: ↑ 22 mackensen14 months ago

  • Cc mackensen added
  • Version set to 3.5.1

Replying to wpmuguru:

Can anyone reproduce this in an install with no plugins and sites that are created with the Network Admin -> Add Site screen ?

I've just done so with 3.5.1. This was a clean install from a tarball with no plugins and no other users. After adding the new site via Add Site I immediately loaded it and clicked on the "Uncategorized" category, which returned the "this is embarrassing" message. I believe this happens because populate_options() is bringing over the rewrite_rules option from the main site which includes all the blog/etc rules (appropriate for the main site but useless in a subdirectory instance). One method I've found to fix this is to reset the rewrite_rules option immediately after populate_options is done (in the wpmu_create_blog function):

update_option( 'rewrite_rules', array() );

That way the proper rewrite rules get generated on first visit. Hope this helps.

comment:24 SergeyBiryukov14 months ago

  • Version changed from 3.5.1 to 3.0

Version number indicates when the bug was initially introduced/reported.

comment:25 wpmuguru14 months ago

  • Keywords needs-patch added; reporter-feedback removed

I've reproduced the same result & confirmed that the rewrite rules on the new site are the ones for the main site.

comment:26 wp4j11 months ago

I confirm as well that this bug is still present and adding update_option( 'rewrite_rules', array() ); like this seems to fix the issue:

$blog_id = wpmu_create_blog($domain, $path, $title, $wp_user_id, $meta);
			
			switch_to_blog($blog_id);
			update_option( 'rewrite_rules', array() );
			restore_current_blog();

comment:28 follow-up: jeremyfelt8 months ago

  • Milestone changed from Awaiting Review to 3.7

Related #20171 (not entirely sure it's a duplicate yet, but it's close)

comment:29 in reply to: ↑ 28 mackensen8 months ago

Replying to jeremyfelt:

Related #20171 (not entirely sure it's a duplicate yet, but it's close)

Sounds like the exact same issue to me.

comment:30 duck_8 months ago

  • Milestone 3.7 deleted
  • Resolution set to invalid
  • Status changed from new to closed

The issue being described by mackensen and others when creating new sites is a duplicate of #20171. However, the original issue is about broken rewrite rules when upgrading multisite.

The OP's issue was caused by Nextgen Gallery flushing rewrite rules on site upgrade. It used to have a function hooked into `wpmu_upgrade_site` that would call an upgrade routine that would flush rewrite rules. However, the hook runs in the context of the site from which the upgrade is performed (the main site) and so the regenerated rewrite rules were incorrect. Looks like this stuff was removed from ngg in version 1.9.9.

Note: See TracTickets for help on using tickets.