diff --git a/src/wp-admin/includes/user.php b/src/wp-admin/includes/user.php
index 269d64fb26..30f29a42ba 100644
|
a
|
b
|
function edit_user( $user_id = 0 ) {
|
| 45 | 45 | |
| 46 | 46 | $pass1 = $pass2 = ''; |
| 47 | 47 | if ( isset( $_POST['pass1'] ) ) { |
| 48 | | $pass1 = $_POST['pass1']; |
| | 48 | $pass1 = trim( $_POST['pass1'] ); |
| 49 | 49 | } |
| 50 | 50 | if ( isset( $_POST['pass2'] ) ) { |
| 51 | | $pass2 = $_POST['pass2']; |
| | 51 | $pass2 = trim( $_POST['pass2'] ); |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | if ( isset( $_POST['role'] ) && current_user_can( 'edit_users' ) ) { |
diff --git a/tests/phpunit/tests/user.php b/tests/phpunit/tests/user.php
index bcfa036d37..e6c7c5ccb6 100644
|
a
|
b
|
class Tests_User extends WP_UnitTestCase {
|
| 1362 | 1362 | * Checks that calling edit_user() with no password returns an error when adding, and doesn't when updating. |
| 1363 | 1363 | * |
| 1364 | 1364 | * @ticket 35715 |
| | 1365 | * @ticket 42766 |
| 1365 | 1366 | */ |
| 1366 | 1367 | function test_edit_user_blank_pw() { |
| 1367 | 1368 | $_POST = $_GET = $_REQUEST = array(); |
| … |
… |
class Tests_User extends WP_UnitTestCase {
|
| 1398 | 1399 | $this->assertInternalType( 'int', $user_id ); |
| 1399 | 1400 | $this->assertEquals( 'nickname_updated', $user->nickname ); |
| 1400 | 1401 | |
| | 1402 | // Check not to change an old password if a new password contains only spaces. Ticket #42766 |
| | 1403 | $user = get_user_by( 'ID', $user_id ); |
| | 1404 | $old_pass = $user->user_pass; |
| | 1405 | $_POST['pass1'] = $_POST['pass2'] = ' '; |
| | 1406 | |
| | 1407 | $user_id = edit_user( $user_id ); |
| | 1408 | $user = get_user_by( 'ID', $user_id ); |
| | 1409 | |
| | 1410 | $this->assertInternalType( 'int', $user_id ); |
| | 1411 | $this->assertEquals( $old_pass, $user->user_pass ); |
| | 1412 | |
| 1401 | 1413 | // Check updating user with missing second password. |
| 1402 | 1414 | $_POST['nickname'] = 'nickname_updated2'; |
| 1403 | 1415 | $_POST['pass1'] = 'blank_pass2'; |