[wp-trac] [WordPress Trac] #36961: wp_roles displays incorrect roles in multisite

WordPress Trac noreply at wordpress.org
Tue Aug 29 03:11:05 UTC 2017


#36961: wp_roles displays incorrect roles in multisite
-------------------------------------------------+-------------------------
 Reporter:  ryanduff                             |       Owner:  flixos90
     Type:  defect (bug)                         |      Status:  reviewing
 Priority:  normal                               |   Milestone:  4.9
Component:  Role/Capability                      |     Version:  4.2
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch has-unit-tests needs-dev-  |     Focuses:  multisite
  note                                           |
-------------------------------------------------+-------------------------

Comment (by jeremyfelt):

 To sum up the ticket so far, it looks like 2 issues:

 * The role dropdowns on `wp-admin/network/site-users.php` show only the
 roles of the main site. See [attachment:36961.7.diff] for a quick/possible
 approach on that.
 * When called from site 1, `new WP_User( $user_id, '', 2 )` provides a
 user object that contains only roles assigned to the user that exist on
 both site 1 and 2. This is primarily because `wp_roles()` is used to
 populate available roles without switching site context.

 I added [attachment:36961.7.diff] to handle the first case. I don't think
 that was addressed in the other patches on this ticket.

 [attachment:36961.6.diff] looks good so far. I think my only concern is
 the removal of the protected `_init_caps()`. I think we should leave
 `__call()` in for at least the near term. I was able to find a handful of
 unit tests via GitHub that use `_init_caps()` to work around some stuff.
 We can show a deprecated notice instead of causing a fatal for 4.9.

 At a glance it looks like `wp_get_users_with_no_role()` and
 `count_users()` could also return incorrect data when called for another
 site, even though site ID is supported as a passed parameter. It's
 unlikely for these, but we may want new tickets to cover that as well.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/36961#comment:21>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list