Make WordPress Core

Opened 11 years ago

Closed 11 years ago

#25128 closed defect (bug) (invalid)

Remove unreachable code in get_active_blog_for_user()

Reported by: jeremyfelt's profile jeremyfelt Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Multisite Keywords:
Focuses: Cc:

Description

get_active_blog_for_user() accounts for a case where get_user_meta( $user_id, 'primary_blog', true ); returns false. I believe the only possible way for this to happen is via a misguided filter on get_user_metadata.

If for some reason false was returned, the existing code sets the user as a subscriber on the first site it finds the user has access to, overwriting any existing capabilities. (See also #15316)

The function then returns a blog object that may not meet the full expectations of a blog object being returned by the function. (See also #18789)

The attached patch removes this extra, unnecessary code.

Attachments (1)

25128.diff (1.7 KB) - added by jeremyfelt 11 years ago.

Download all attachments as: .zip

Change History (5)

@jeremyfelt
11 years ago

#2 @nacin
11 years ago

I believe the only possible way for this to happen is via a misguided filter on get_user_metadata.

It seems like this could also occur if a user simply doesn't have a primary_blog. This could happen on initial conversion from single-site to multisite, or if user tables are shared, I guess.

#3 @nacin
11 years ago

  • Milestone changed from 3.7 to Awaiting Review

#4 @jeremyfelt
11 years ago

  • Keywords has-patch removed
  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed
  • Version 3.0 deleted

If a user is a member of at least one blog, and has no primary blog assigned, then this could be reached.

I haven't tested how to trigger that scenario, but the code itself appears harmless either way.

Note: See TracTickets for help on using tickets.