hellofromTonya
d7893c3cea
Code Modernization: Fix null to non-nullable deprecation in WP_REST_Users_Controller::update_item()
.
...
Not all requests are accompanied by a `$request['email']`. This leads to a PHP 8.1 "passing null to non-nullable" deprecation notice when the `WP_REST_Users_Controller::update_item()` method passes a `null` email address onto `email_exists()`, which eventually reached the `WP_User::get_data_by()` method where things go wrong.
In the next condition in the code of the `WP_REST_Users_Controller::update_item()` method - `if ( $owner_id && $owner_id !== $id )` - you can see that the code already takes this into account as it will not throw a `WP_Error` if `$owner_id` is falsey.
`WP_User::get_data_by()` returns `false` for a failed field request. The other functions through which the return value is passed through, do the same.
So, by setting a default value for `$owner_id` of `false` and only checking `email_exists()` when there is an email to check, the "passing null to non-nullable" deprecation notice is bypassed without breaking BC.
Fixes a whole slew of test errors along the lines of:
{{{
6) WP_Test_REST_Users_Controller::test_update_item_en_US_locale
trim(): Passing null to parameter https://github.com/WordPress/wordpress-develop/pull/1 ($string) of type string is deprecated
/var/www/src/wp-includes/class-wp-user.php:211
/var/www/src/wp-includes/pluggable.php:105
/var/www/src/wp-includes/user.php:1953
/var/www/src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php:728
/var/www/src/wp-includes/rest-api/class-wp-rest-server.php:1143
/var/www/src/wp-includes/rest-api/class-wp-rest-server.php:990
/var/www/tests/phpunit/includes/spy-rest-server.php:67
/var/www/tests/phpunit/tests/rest-api/rest-users-controller.php:1719
/var/www/vendor/bin/phpunit:123
}}}
Follow-up to [44641], [38832].
Props jrf.
See #55656 .
Built from https://develop.svn.wordpress.org/trunk@54317
git-svn-id: http://core.svn.wordpress.org/trunk@53876 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-26 21:46:09 +00:00
..
2022-09-23 20:04:13 +00:00
2022-04-12 09:26:16 +00:00
2022-09-26 14:58:12 +00:00
2022-09-21 20:57:12 +00:00
2022-09-20 15:43:29 +00:00
2022-09-12 15:47:14 +00:00
2021-11-26 03:06:03 +00:00
2021-11-16 00:04:01 +00:00
2022-09-23 20:04:13 +00:00
2022-04-06 15:20:06 +00:00
2022-08-22 12:26:12 +00:00
2022-09-26 20:56:10 +00:00
2022-02-16 21:19:04 +00:00
2021-12-06 21:30:03 +00:00
2022-09-26 21:46:09 +00:00
2021-12-20 19:33:00 +00:00
2022-09-12 15:47:14 +00:00
2022-09-26 14:00:10 +00:00
2022-09-14 12:48:16 +00:00
2022-03-22 16:25:03 +00:00
2022-03-22 16:25:03 +00:00
2022-09-20 10:31:14 +00:00
2022-08-13 22:44:09 +00:00
2022-04-21 11:24:17 +00:00
2022-09-20 16:26:10 +00:00
2022-09-23 14:00:09 +00:00
2022-09-20 16:29:12 +00:00
2022-09-21 15:45:12 +00:00
2022-09-20 10:31:14 +00:00
2022-09-26 13:07:14 +00:00
2022-06-23 22:57:12 +00:00
2022-08-30 15:17:08 +00:00
2022-07-23 14:58:12 +00:00
2022-07-23 14:58:12 +00:00
2022-04-01 03:25:01 +00:00
2022-09-20 15:45:49 +00:00
2022-08-19 23:06:09 +00:00
2022-08-04 14:52:11 +00:00
2022-06-17 11:20:13 +00:00
2022-08-31 13:41:08 +00:00
2022-06-17 11:20:13 +00:00
2021-12-06 21:30:03 +00:00
2021-12-24 18:06:06 +00:00
2021-01-26 13:45:57 +00:00
2022-01-30 19:25:03 +00:00
2022-01-30 19:25:03 +00:00
2022-01-30 19:25:03 +00:00
2022-09-15 12:32:08 +00:00
2022-05-01 22:01:10 +00:00
2022-01-30 19:25:03 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2022-09-20 15:43:29 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2022-09-19 19:51:09 +00:00
2022-09-14 10:52:08 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 21:50:14 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2022-09-20 14:17:12 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2022-09-20 10:31:14 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2021-12-06 21:30:03 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2022-09-19 22:53:10 +00:00
2022-09-19 22:53:10 +00:00
2022-09-20 16:59:10 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2022-09-20 14:26:10 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2022-09-20 11:57:20 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2022-09-19 20:49:10 +00:00
2022-09-20 14:17:12 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2022-09-20 14:17:12 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2022-09-20 13:13:21 +00:00
2022-09-23 21:31:10 +00:00
2022-09-12 15:47:14 +00:00
2022-09-26 10:17:11 +00:00
2022-09-20 01:36:09 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2022-09-20 13:12:10 +00:00
2022-09-20 02:51:09 +00:00
2022-09-20 14:17:12 +00:00
2022-09-20 14:17:12 +00:00
2022-09-20 14:17:12 +00:00
2022-09-12 17:52:08 +00:00
2022-08-26 01:03:14 +00:00
2022-05-08 00:29:14 +00:00
2022-09-20 20:32:09 +00:00
2022-06-17 11:20:13 +00:00
2022-09-20 01:36:09 +00:00
2022-09-21 15:06:12 +00:00
2022-09-21 19:48:13 +00:00
2022-06-17 11:20:13 +00:00
2022-08-19 22:06:09 +00:00
2022-04-29 19:17:11 +00:00
2021-11-29 09:52:00 +00:00
2022-06-20 21:46:16 +00:00
2022-09-20 14:17:12 +00:00
2022-09-26 13:07:14 +00:00
2022-04-04 18:26:06 +00:00
2021-11-19 15:14:00 +00:00
2022-09-22 09:26:15 +00:00
2022-09-14 18:44:09 +00:00
2022-09-14 13:08:14 +00:00
2022-08-11 14:11:08 +00:00
2022-09-15 13:29:13 +00:00
2022-09-19 19:51:09 +00:00
2022-09-13 18:05:09 +00:00
2022-09-20 15:45:49 +00:00
2022-09-20 04:02:10 +00:00
2022-09-20 10:31:14 +00:00
2022-08-11 14:03:09 +00:00
2022-09-06 11:28:13 +00:00
2022-07-14 13:35:13 +00:00
2022-09-20 02:51:09 +00:00
2022-09-21 19:48:13 +00:00
2021-07-06 20:21:57 +00:00
2022-09-20 02:51:09 +00:00
2022-05-13 12:21:13 +00:00
2022-09-06 11:28:13 +00:00
2022-08-26 01:03:14 +00:00
2022-02-07 14:01:05 +00:00
2022-06-15 13:37:10 +00:00
2022-09-20 20:32:09 +00:00
2022-09-21 20:24:12 +00:00
2022-08-01 11:15:14 +00:00
2022-09-21 20:24:12 +00:00
2022-03-15 15:22:05 +00:00
2022-09-21 20:24:12 +00:00
2022-06-21 13:34:13 +00:00
2020-11-12 11:17:07 +00:00
2022-08-11 14:03:09 +00:00
2022-08-11 14:03:09 +00:00
2022-08-07 23:05:10 +00:00
2022-04-06 15:33:03 +00:00
2022-03-22 16:25:03 +00:00
2022-09-23 08:27:12 +00:00
2022-09-20 10:31:14 +00:00
2022-09-14 12:48:16 +00:00
2022-09-20 18:53:09 +00:00
2021-12-10 20:30:05 +00:00
2022-09-21 01:09:10 +00:00
2022-09-21 11:43:13 +00:00
2022-05-02 13:13:08 +00:00
2022-09-14 18:44:09 +00:00
2022-09-15 12:20:09 +00:00
2022-09-22 11:13:14 +00:00
2022-09-20 16:26:10 +00:00
2022-04-27 13:47:11 +00:00
2022-09-26 21:46:09 +00:00
2022-06-01 18:14:10 +00:00
2022-07-21 22:45:11 +00:00