[wp-trac] [WordPress Trac] #54984: wp_update_user doesn't work properly with current user instance
WordPress Trac
noreply at wordpress.org
Fri Mar 11 03:30:38 UTC 2022
#54984: wp_update_user doesn't work properly with current user instance
--------------------------+---------------------
Reporter: oztaser | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: 6.0
Component: Users | Version:
Severity: normal | Resolution:
Keywords: | Focuses:
--------------------------+---------------------
Comment (by dd32):
> However, I am not sure this is an ideal solution as get_userdata() and
related functions are pluggable so there is no way of knowing if the data
returned by new WP_User( $user_id ) is what is returned by get_userdata().
Thinking out-loud here: If we're only expecting a `WP_User` object in
these places/globals, and since we've got a `WP_User::__set()` that takes
care of `$user->user_pass = 12345;`, `WP_User` could create a copy of the
user-data prior to altering fields values and a `WP_User::has_changed(
'user_pass' )` could be used to detect if the object has changed / what
fields have changed.
That doesn't take care of a situation where `$user->data->user_pass` is
changed directly though.
So perhaps [attachment:"54984.diff"] is indeed the ideal way forward.
> However, I am not sure this is an ideal solution as get_userdata() and
related functions are pluggable so there is no way of knowing if the data
returned by new WP_User( $user_id ) is what is returned by get_userdata().
Correct me if I'm wrong, but in those cases, this could've previously been
an issue too, right?
--
Ticket URL: <https://core.trac.wordpress.org/ticket/54984#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list