Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#18789 closed defect (bug) (fixed)

get_active_blog_for_user() expects a more decorated blog object

Reported by: nacin Owned by:
Milestone: 3.3 Priority: normal
Severity: normal Version:
Component: Multisite Keywords:
Focuses: Cc:


If the user has no primary_blog set yet, we chop off the first blog returned in get_blogs_of_user(), set that ID as the primary_blog, and let the function continue.

The issue is a line of code that expects if $primary is an object, then it has the archived, spam, and deleted properties set.

This is only the case if the blog object came from get_blog_details() (as in, the primary_blog has already been set). For whatever reason, get_blogs_of_user() does not bother to return such details.

The fix is to ensure that, when no primary blog is available, we pull the new primary blog's full details from get_blog_details(), rather than relying on the object we already have.

On the next call to get_active_blog_for_user(), primary_blog will be set, so the function call only affects first-run situations.

Change History (1)

#1 @nacin
4 years ago

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


I noticed this bug from the notices it spit out, after logging in under an existing account after toggling a test install to multisite.

Note: See TracTickets for help on using tickets.