WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#13530 closed enhancement (duplicate)

Should switch_to_blog() call $wp_rewrite->init(); ?

Reported by: jimisaacs Owned by: wpmuguru
Milestone: Priority: normal
Severity: normal Version: 3.0
Component: Multisite Keywords: swtich_to_blog, wp_rewrite
Focuses: Cc:

Description

This is more of a question than a report, because I am still not quite sure what the intended outcome or procedure is when using switch_to_blog().

My current usage is, get_blog_list()
Loop through the list calling switch_to_blog(), and then restore_current_blog() for each iteration.

This is the way I used to do things with MU, now I am getting weird outcomes having to do with permalink structures for post taxonomies.

These all seem to disappear when I call $wp_rewrite->init() along with the previous calls. So I was wondering what am I doing wrong? Or should this call be included in switch_to_blog() ?

Change History (7)

comment:1 nacin4 years ago

  • Owner set to wpmuguru
  • Status changed from new to assigned

comment:2 ryan4 years ago

Re-initializing rewrite after switch_to_blog() has always been rather undefined. To do it properly would require unloading and reloading all plugins.

comment:3 ryan4 years ago

Initializing rewrite in switch_to_blog() probably wouldn't hurt though.

comment:4 ryan4 years ago

Could you document the weird outcomes so we can see if there are underlying causes we need to address beyond doing an init().

comment:5 ryan4 years ago

init() is pretty expensive so it probably won't be added to switch_to_blog(). Are you using custom posts or taxonomies? If so, are they being defined for all blogs (the entire site) or only certain blogs.

comment:6 wpmuguru4 years ago

  • Resolution set to duplicate
  • Status changed from assigned to closed

Closing this as a duplicate of #12040.

comment:7 nacin4 years ago

  • Milestone 3.0 deleted
Note: See TracTickets for help on using tickets.