[wp-trac] [WordPress Trac] #64628: wp_set_current_user() is type strict determing current user
WordPress Trac
noreply at wordpress.org
Wed Feb 11 23:56:53 UTC 2026
#64628: wp_set_current_user() is type strict determing current user
---------------------------+--------------------
Reporter: peterwilsoncc | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: 7.0
Component: Users | Version:
Severity: normal | Keywords:
Focuses: performance |
---------------------------+--------------------
The `wp_set_current_user()` function returns early if the function is
called with the current user ID to avoid the work of switching users when
it's not required.
However, the function uses a type strict comparison when determining if
the user ID is the same, so `wp_set_current_user( (int)
get_current_user_id() )` will return early, whereas `wp_set_current_user(
(string) get_current_user_id() )` will proceed through the set up of the
new current user.
Introduced in r57882 for #60700.
This is a minor fix (tests and PR incoming) so I've put it on the 7.0
milestone.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/64628>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list