WordPress.org

Make WordPress Core

Opened 2 years ago

Last modified 6 weeks ago

#16201 new defect (bug)

when updating a multisite blog subblogs getting 404 error

Reported by: YogieAnamCara Owned by:
Priority: normal Milestone: Awaiting Review
Component: Multisite Version: 3.0
Severity: normal Keywords: needs-patch
Cc: arnonel, mariusmandal, ipstenu@…, georgemamadashvili@…, mgyura, mackensen

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 4 months ago.

Download all attachments as: .zip

Change History (27)

comment:1 YogieAnamCara2 years ago

  • Component changed from General to Multisite

comment:2 follow-up: garyc402 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 garyc402 years ago

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

comment:5 nacin2 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 yogieanamcara2 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: yogieanamcara2 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: SergeyBiryukov2 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: SergeyBiryukov2 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 yogieanamcara2 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.

/wp-admin/ms-upgrade-network.php

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

comment:11 in reply to: ↑ 8 ; follow-up: yogieanamcara2 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 SergeyBiryukov2 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 yogieanamcara2 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 2 years ago by yogieanamcara (previous) (diff)

comment:14 yogieanamcara2 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: arnonel22 months 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 arnonel22 months ago

  • Cc arnonel added
  • Severity changed from major to critical

comment:17 in reply to: ↑ 15 SergeyBiryukov22 months 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 mariusmandal21 months 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 Ipstenu13 months ago

  • Cc ipstenu@… added

comment:20 Mamaduka13 months ago

  • Cc georgemamadashvili@… added

comment:21 mgyura10 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 & Addons
WordPress SEO

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

Version 0, edited 10 months ago by mgyura (next)

comment:22 follow-up: wpmuguru8 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 mackensen4 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 SergeyBiryukov4 months ago

  • Version changed from 3.5.1 to 3.0

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

comment:25 wpmuguru4 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 wp4j6 weeks 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();
Note: See TracTickets for help on using tickets.