[wp-trac] [WordPress Trac] #14308: wp_insert_user in 3.0 is not backwards compatible
WordPress Trac
wp-trac at lists.automattic.com
Thu Jul 15 02:02:10 UTC 2010
#14308: wp_insert_user in 3.0 is not backwards compatible
--------------------------+-------------------------------------------------
Reporter: ahupp | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: 3.1
Component: Users | Version: 3.0
Severity: normal | Keywords: has-patch
--------------------------+-------------------------------------------------
Comment(by coffee2code):
Also see the related #14290.
There I'm fixing a downstream manifestation of this change introduced in
3.0 (`register_new_user()` in wp-login.php was expecting an int instead of
a possible WP_Error).
We have to decide if we want to support the older (int) return value (as
patched in this ticket) or allow the functions to potentially return
WP_Error and change things accordingly within core. As filosofo pointed
out, it's already out there, so people are likely building stuff with
`wp_insert_user()` and `wp_create_user()` now possibly returning WP_Error.
I favor keeping the new behavior and having everything return a WP_Error
rather than 0 if something is wrong. This creates consistency with the
return values between `wp_create_user()`, `wp_insert_user()`, and
`wp_update_user()`. We already broke backwards compatibility with the 3.0
change to `wp_insert_user()` (which I don't believe anyone is suggesting
should be reverted), so there isn't much more harm in doing the same for
the other two related functions (as long as we make sure it is properly
handled throughout the code).
Bear in mind too that the WP_Error object is passing along the error
message. We'll lose (and prevent outside code from recognizing)
potentially beneficial information by simply swallowing it and returning
0.
I fear the consensus may be to break 3.0 compatibility to resume pre-3.0
compatibility for 2 of the 3 related functions. In which case some may
want to roll with something equivalent to:
{{{
function is_valid_user( $user ) {
return ( !is_wp_error( $user ) && $user );
}
}}}
--
Ticket URL: <http://core.trac.wordpress.org/ticket/14308#comment:2>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list