#38430 closed defect (bug) (fixed)
Inconsistent return type in `get_active_blog_for_user()`
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 5.1 | Priority: | normal |
| Severity: | normal | Version: | |
| Component: | Networks and Sites | Keywords: | has-patch |
| Focuses: | multisite | Cc: |
Description
While writing unit tests for #38355, I discovered that get_active_blog_for_user() may possibly return a plain object like those in the array returned by get_blogs_of_user(). We should make sure that only WP_Site objects are returned.
On the other hand, this issue is not really critical since, as far as I could see, the entire clause starting with ! is_object(... will never be reached - I might have missed a use-case, but I tried several "combinations" of what could happen, but never got to the point where it was executed.
Attachments (1)
Change History (5)
Note: See
TracTickets for help on using
tickets.
This statement should be reachable if the user's
primary_bloghappens to be set as archived, spam, or deleted.What I don't get is that we do another call to
get_blogs_of_user()and pass the second parameter to get a list of all sites, including those set as archived, spam, or deleted. We then ignore those when trying to find a new primary to set for the user. That's probably another ticket.Quite a bit about this could be refactored, but 38430.diff is pretty non-intrusive and should result in a consistent
WP_Sitereturn as we already have a better object available to us.