[wp-trac] [WordPress Trac] #38645: Improve roles reinit when switching between sites

WordPress Trac noreply at wordpress.org
Wed Sep 27 21:44:00 UTC 2017


#38645: Improve roles reinit when switching between sites
-------------------------------------------------+-------------------------
 Reporter:  johnjamesjacoby                      |       Owner:  flixos90
     Type:  defect (bug)                         |      Status:  closed
 Priority:  normal                               |   Milestone:  4.9
Component:  Role/Capability                      |     Version:  4.7
 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:"41625"]:
 {{{
 #!CommitTicketReference repository="" revision="41625"
 Multisite: Improve initializing available roles when switch sites.

 Switching the available roles and the current user's capabilities no
 longer happens in `switch_to_blog()` and `restore_current_blog()`, instead
 it has been moved to a new function `wp_switch_roles_and_user()` which is
 hooked into the site switching process. This allows to improve performance
 by temporarily unhooking the function when roles and capabilities do not
 need to be switched.

 This change ensures that switching available roles now works closer to
 switching user capabilities, particularly the changes in [41624]. A new
 `WP_Roles::for_site( $site_id )` method has been introduced, and the
 `WP_Roles::_init()` method has been deprecated. It is furthermore possible
 to retrieve the site ID for which the available roles are currently
 initialized through a new `WP_Roles::get_site_id()`.

 Props johnjamesjacoby, flixos90.
 Fixes #38645.
 }}}

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


More information about the wp-trac mailing list