Make WordPress Core

Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#16444 closed defect (bug) (fixed)

add_user_to_blog() and remove_user_from_blog() can break the switch_to_blog() stack

Reported by: mdawaffe's profile mdawaffe Owned by: markjaquith's profile markjaquith
Milestone: 3.1 Priority: normal
Severity: normal Version: 3.0.1
Component: Users Keywords: has-patch dev-feedback
Focuses: Cc:

Description

Both add_user_to_blog() and remove_user_from_blog() call switch_to_blog() first thing. On encountering an error, however, they can return before calling restore_current_blog().

See #13903

Patch attached.

Attachments (1)

16444.diff (834 bytes) - added by mdawaffe 14 years ago.

Download all attachments as: .zip

Change History (7)

@mdawaffe
14 years ago

#1 @markjaquith
14 years ago

  • Keywords dev-feedback added
  • Milestone changed from Awaiting Review to 3.1
  • Owner set to markjaquith
  • Status changed from new to accepted

Straightforward fix, for what could be a tricky bug to track down if encountered. Can I get some more people to weigh in?

#2 follow-up: @nacin
14 years ago

Looks good -- wondering if there are other places we're doing the same thing.

#3 @PeteMall
14 years ago

+1 from me as discussed in the IRC channel.

#4 in reply to: ↑ 2 @PeteMall
14 years ago

Replying to nacin:

Looks good -- wondering if there are other places we're doing the same thing.

Just browsed through all instances of switch_to_blog and doesn't look like we're doing this anywhere else.

Last edited 14 years ago by PeteMall (previous) (diff)

#5 @markjaquith
14 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed

(In [17379]) restore_current_blog() in add_user_to_blog() and remove_user_from_blog() before early return, to avoid being stuck in a switched state. props mdawaffe. fixes #16444 for trunk.

#6 @markjaquith
14 years ago

(In [17380]) restore_current_blog() in add_user_to_blog() and remove_user_from_blog() before early return, to avoid being stuck in a switched state. props mdawaffe. fixes #16444 for trunk.

Note: See TracTickets for help on using tickets.