diff --git src/wp-includes/user-functions.php src/wp-includes/user-functions.php
index a79d1e8..e03cc17 100644
|
|
|
function wp_insert_user( $userdata ) {
|
| 1275 | 1275 | } elseif ( $userdata instanceof WP_User ) { |
| 1276 | 1276 | $userdata = $userdata->to_array(); |
| 1277 | 1277 | } |
| | 1278 | |
| 1278 | 1279 | // Are we updating or creating? |
| 1279 | 1280 | if ( ! empty( $userdata['ID'] ) ) { |
| 1280 | 1281 | $ID = (int) $userdata['ID']; |
| 1281 | 1282 | $update = true; |
| 1282 | | $old_user_data = WP_User::get_data_by( 'id', $ID ); |
| | 1283 | $old_user_data = get_userdata( $ID ); |
| | 1284 | |
| | 1285 | if ( ! $old_user_data ) { |
| | 1286 | return new WP_Error( 'invalid_user_id', __( 'Invalid user ID.' ) ); |
| | 1287 | } |
| | 1288 | |
| 1283 | 1289 | // hashed in wp_update_user(), plaintext if called directly |
| 1284 | 1290 | $user_pass = $userdata['user_pass']; |
| 1285 | 1291 | } else { |
diff --git tests/phpunit/tests/user.php tests/phpunit/tests/user.php
index f0b60d1..8faa06f 100644
|
|
|
class Tests_User extends WP_UnitTestCase {
|
| 757 | 757 | $this->assertSame( $expected, $user->user_nicename ); |
| 758 | 758 | } |
| 759 | 759 | |
| | 760 | /** |
| | 761 | * @ticket 28004 |
| | 762 | */ |
| | 763 | public function test_wp_insert_user_with_invalid_user_id() { |
| | 764 | $user_login = str_repeat( 'a', 55 ); |
| | 765 | $u = wp_insert_user( array( |
| | 766 | 'ID' => 123, |
| | 767 | 'user_login' => $user_login, |
| | 768 | 'user_email' => $user_login . '@example.com', |
| | 769 | 'user_pass' => 'password', |
| | 770 | ) ); |
| | 771 | |
| | 772 | $this->assertWPError( $u ); |
| | 773 | } |
| | 774 | |
| 760 | 775 | function test_changing_email_invalidates_password_reset_key() { |
| 761 | 776 | global $wpdb; |
| 762 | 777 | |
| … |
… |
class Tests_User extends WP_UnitTestCase {
|
| 963 | 978 | $user = get_userdata( $testuserid ); |
| 964 | 979 | $pwd_before = $user->user_pass; |
| 965 | 980 | wp_update_user( $user ); |
| 966 | | |
| | 981 | |
| 967 | 982 | // Reload the data |
| 968 | 983 | $pwd_after = get_userdata( $testuserid )->user_pass; |
| 969 | 984 | $this->assertEquals( $pwd_before, $pwd_after ); |