user: Remove deprecated and unused method `getPasswordValidity()`
authorDerick Alangi <alangiderick@gmail.com>
Thu, 9 May 2019 22:31:17 +0000 (23:31 +0100)
committerDerick Alangi <alangiderick@gmail.com>
Thu, 9 May 2019 23:13:20 +0000 (00:13 +0100)
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
includes/user/User.php
tests/phpunit/includes/user/UserTest.php

index ae20991..4b31c07 100644 (file)
@@ -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 ===
index 2f6deb5..18d62f5 100644 (file)
@@ -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
         *
index aeeae11..c90e988 100644 (file)
@@ -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' ) );
        }
 
        /**