[buddypress-trac] [BuddyPress Trac] #6240: restore_current_blog() being called when not needed, causing issues with some plugins

buddypress-trac noreply at wordpress.org
Fri Feb 20 17:08:31 UTC 2015


#6240: restore_current_blog() being called when not needed, causing issues with
some plugins
--------------------------+------------------------------
 Reporter:  sj-xweb       |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  API           |     Version:
 Severity:  normal        |  Resolution:
 Keywords:                |
--------------------------+------------------------------

Comment (by johnjamesjacoby):

 Interesting. We can add a root blog check, and have done so in at least
 one other place in the past. I'm more curious what the use case is for
 switching once and not switching back. I have a hunch many plugins are not
 prepared for this, including ones that register or rely on any custom post
 types.

 switch_to_blog() went through several iterations in the early days, and I
 recall it working the way you mention, where switches were, basically
 wound up and down. Each switch required a restore, even if a switch
 switched to the same blog 5 times in a row. This means switching without
 restoring was a bit of sabotage, and what our code here represents is a
 fine working example of that.

 If necessary, I'm fine adding a bp_is_root_blog() check, and since we are
 storing things in the root blog increasingly often, we may want wrapper
 functions to more confidently switch around.

--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/6240#comment:1>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac


More information about the buddypress-trac mailing list