From fffadf725e3f3ec0196b53f8b1542b5f761a36f9 Mon Sep 17 00:00:00 2001 From: Derick Alangi Date: Thu, 9 May 2019 23:31:17 +0100 Subject: [PATCH] user: Remove deprecated and unused method `getPasswordValidity()` This method was deprecated in 1.33 and no longer used. See usage; Usage ===== https://codesearch.wmflabs.org/search/?q=%5CbgetPasswordValidity%5Cb&i=nope&files=&repos= Bug: T220656 Change-Id: I28829f33d40b5568bedb9678fc43beb146b72e56 --- RELEASE-NOTES-1.34 | 1 + includes/user/User.php | 29 ------------------------ tests/phpunit/includes/user/UserTest.php | 6 ----- 3 files changed, 1 insertion(+), 35 deletions(-) diff --git a/RELEASE-NOTES-1.34 b/RELEASE-NOTES-1.34 index ae20991e38..4b31c07ee2 100644 --- a/RELEASE-NOTES-1.34 +++ b/RELEASE-NOTES-1.34 @@ -145,6 +145,7 @@ because of Phabricator reports. deprecated in 1.32, have been removed. * OutputPage::getModuleScripts(), ParserOutput::getModuleScripts(), deprecated in 1.33, have been removed. +* User::getPasswordValidity(), deprecated in 1.33, has been removed. * … === Deprecations in 1.34 === diff --git a/includes/user/User.php b/includes/user/User.php index 2f6deb5f48..18d62f5a38 100644 --- a/includes/user/User.php +++ b/includes/user/User.php @@ -1162,35 +1162,6 @@ class User implements IDBAccessObject, UserIdentity { return $this->checkPasswordValidity( $password )->isGood(); } - /** - * Given unvalidated password input, return error message on failure. - * - * @param string $password Desired password - * @return bool|string|array True on success, string or array of error message on failure - * @deprecated since 1.33, use checkPasswordValidity - */ - public function getPasswordValidity( $password ) { - wfDeprecated( __METHOD__, '1.33' ); - - $result = $this->checkPasswordValidity( $password ); - if ( $result->isGood() ) { - return true; - } - - $messages = []; - foreach ( $result->getErrorsByType( 'error' ) as $error ) { - $messages[] = $error['message']; - } - foreach ( $result->getErrorsByType( 'warning' ) as $warning ) { - $messages[] = $warning['message']; - } - if ( count( $messages ) === 1 ) { - return $messages[0]; - } - - return $messages; - } - /** * Check if this is a valid password for this user * diff --git a/tests/phpunit/includes/user/UserTest.php b/tests/phpunit/includes/user/UserTest.php index aeeae11833..c90e98890e 100644 --- a/tests/phpunit/includes/user/UserTest.php +++ b/tests/phpunit/includes/user/UserTest.php @@ -366,7 +366,6 @@ class UserTest extends MediaWikiTestCase { * - ensure the password is not the same as the username * - ensure the username/password combo isn't forbidden * @covers User::checkPasswordValidity() - * @covers User::getPasswordValidity() * @covers User::isValidPassword() */ public function testCheckPasswordValidity() { @@ -394,7 +393,6 @@ class UserTest extends MediaWikiTestCase { ], ], ] ); - $this->hideDeprecated( 'User::getPasswordValidity' ); $user = static::getTestUser()->getUser(); @@ -405,24 +403,20 @@ class UserTest extends MediaWikiTestCase { $this->assertFalse( $user->isValidPassword( 'a' ) ); $this->assertFalse( $user->checkPasswordValidity( 'a' )->isGood() ); $this->assertTrue( $user->checkPasswordValidity( 'a' )->isOK() ); - $this->assertEquals( 'passwordtooshort', $user->getPasswordValidity( 'a' ) ); // Maximum length $longPass = str_repeat( 'a', 41 ); $this->assertFalse( $user->isValidPassword( $longPass ) ); $this->assertFalse( $user->checkPasswordValidity( $longPass )->isGood() ); $this->assertFalse( $user->checkPasswordValidity( $longPass )->isOK() ); - $this->assertEquals( 'passwordtoolong', $user->getPasswordValidity( $longPass ) ); // Matches username $this->assertFalse( $user->checkPasswordValidity( $user->getName() )->isGood() ); $this->assertTrue( $user->checkPasswordValidity( $user->getName() )->isOK() ); - $this->assertEquals( 'password-name-match', $user->getPasswordValidity( $user->getName() ) ); // On the forbidden list $user = User::newFromName( 'Useruser' ); $this->assertFalse( $user->checkPasswordValidity( 'Passpass' )->isGood() ); - $this->assertEquals( 'password-login-forbidden', $user->getPasswordValidity( 'Passpass' ) ); } /** -- 2.20.1