Opened 3 weeks ago
Closed 3 weeks ago
#64628 closed defect (bug) (fixed)
wp_set_current_user() is type strict determing current user
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 7.0 | Priority: | normal |
| Severity: | normal | Version: | |
| Component: | Users | Keywords: | has-patch has-unit-tests |
| Focuses: | performance | Cc: |
Description
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.
Change History (2)
This ticket was mentioned in PR #10905 on WordPress/wordpress-develop by @peterwilsoncc.
3 weeks ago
#1
- Keywords has-patch has-unit-tests added
Note: See
TracTickets for help on using
tickets.
Ensures the user switching does not occur when attempting to switch to the same user with the user ID cast to a string.
Trac ticket: https://core.trac.wordpress.org/ticket/64628
## Use of AI Tools
Nil.