REST API: Remove 'Invalid user ID' error in WP_REST_Users_Controller::update_item().
Removes the `WP_Error` code for `'Invalid user ID.'`. Why? tl;dr This branch will never be entered as the `$user` will never be falsey. Longer reasoning: [39954] introduced `WP_REST_Users_Controller::get_user()` method to encapsulate getting the user and handling the `'Invalid user ID.'` `WP_Error`. It replaced `get_userdata()` in `WP_REST_Users_Controller::update_item()` but left the existing `'Invalid user ID.'` `WP_Error` introduced in [38832]. The code removed in this changeset will never be reached because `$user` will never be falsey. Rather, `WP_REST_Users_Controller::get_user()` will always return an instance of `WP_Error` or `WP_User`. Could the user's ID be falsey? No. Why? `WP_REST_Users_Controller::get_user()` checks that the user exists, which checks if the ID is falsey. Therefore, the code can safely be removed. Follow-up to [39954], [38832]. Props jrf, costdev, hellofromTonya, SergeyBiryukov. Fixes #56662. Built from https://develop.svn.wordpress.org/trunk@55325 git-svn-id: http://core.svn.wordpress.org/trunk@54858 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
371afa317c
commit
5584cf60c0
|
@ -717,14 +717,6 @@ class WP_REST_Users_Controller extends WP_REST_Controller {
|
||||||
|
|
||||||
$id = $user->ID;
|
$id = $user->ID;
|
||||||
|
|
||||||
if ( ! $user ) {
|
|
||||||
return new WP_Error(
|
|
||||||
'rest_user_invalid_id',
|
|
||||||
__( 'Invalid user ID.' ),
|
|
||||||
array( 'status' => 404 )
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
$owner_id = false;
|
$owner_id = false;
|
||||||
if ( is_string( $request['email'] ) ) {
|
if ( is_string( $request['email'] ) ) {
|
||||||
$owner_id = email_exists( $request['email'] );
|
$owner_id = email_exists( $request['email'] );
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '6.2-beta1-55324';
|
$wp_version = '6.2-beta1-55325';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue