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

WordPress Trac noreply at wordpress.org
Wed Sep 27 21:09:13 UTC 2017


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

 * status:  reviewing => closed
 * resolution:   => fixed


Comment:

 In [changeset:"41624"]:
 {{{
 #!CommitTicketReference repository="" revision="41624"
 Multisite: Initialize a user's roles correctly when setting them up for a
 different site.

 While it has always been possible to initialize a user's roles and
 capabilities for another site than the current one in a multisite, the
 actual roles available were not switched prior to this change, possibly
 causing invalid roles to show up or actually valid capabilities not being
 available.

 In order to fix this bug in a clean way, relevant parts of the `WP_User`
 class have been refactored. The ID of the site for which capabilities are
 currently initialized are now stored in a private property
 `WP_User::$site_id`. The `WP_User::for_blog( $blog_id )` and
 `WP_User::_init_caps( $cap_key )` methods have been deprecated in favor of
 `WP_User::for_site( $site_id )`. In addition, a new method
 `WP_User::get_site_id()` has been introduced to retrieve the site ID for
 which the user's capabilities are currently initialized.

 Props ryanduff, jeremyfelt, flixos90.
 Fixes #36961.
 }}}

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


More information about the wp-trac mailing list