[wp-trac] [WordPress Trac] #28020: get_userdata and wp_get_current_user do not share WP_User instance

WordPress Trac noreply at wordpress.org
Mon Apr 26 01:02:48 UTC 2021


#28020: get_userdata and wp_get_current_user do not share WP_User instance
--------------------------------------------+----------------------------
 Reporter:  rmccue                          |       Owner:  peterwilsoncc
     Type:  defect (bug)                    |      Status:  closed
 Priority:  normal                          |   Milestone:  5.8
Component:  Users                           |     Version:
 Severity:  normal                          |  Resolution:  fixed
 Keywords:  has-patch has-unit-tests early  |     Focuses:  rest-api
--------------------------------------------+----------------------------
Changes (by peterwilsoncc):

 * owner:  (none) => peterwilsoncc
 * status:  new => closed
 * resolution:   => fixed


Comment:

 In [changeset:"50790" 50790]:
 {{{
 #!CommitTicketReference repository="" revision="50790"
 Users: Share current user instance across functions.

 Share the `WP_User` instance for the current user between the functions
 `get_userdata()` and `wp_get_current_user()`. Both functions return the
 `$current_user` global for the current user.

 Force refresh the `$current_user` global within `clean_user_cache()` by
 immediately re-calling `wp_set_current_user()` with the current user's ID.
 This ensures any changes to the current user's permissions or other
 settings are reflected in the global. As a side-effect this immediately
 rewarms the current user's cache.

 Props chaion07, chriscct7, donmhico, hellofromtonya, lukecarbis,
 peterwilsoncc, rmccue, TimothyBlynJacobs.
 Fixes #28020.
 }}}

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


More information about the wp-trac mailing list