Merge "RevisionStoreDbTestBase, remove redundant needsDB override"
[lhc/web/wiklou.git] / includes / user / BotPassword.php
index 6b8153c..5762120 100644 (file)
@@ -139,10 +139,8 @@ class BotPassword implements IDBAccessObject {
                        'bp_user' => 0,
                        'bp_app_id' => isset( $data['appId'] ) ? trim( $data['appId'] ) : '',
                        'bp_token' => '**unsaved**',
-                       'bp_restrictions' => isset( $data['restrictions'] )
-                               ? $data['restrictions']
-                               : MWRestrictions::newDefault(),
-                       'bp_grants' => isset( $data['grants'] ) ? $data['grants'] : [],
+                       'bp_restrictions' => $data['restrictions'] ?? MWRestrictions::newDefault(),
+                       'bp_grants' => $data['grants'] ?? [],
                ];
 
                if (
@@ -252,8 +250,7 @@ class BotPassword implements IDBAccessObject {
                        return PasswordFactory::newInvalidPassword();
                }
 
-               $passwordFactory = new \PasswordFactory();
-               $passwordFactory->init( \RequestContext::getMain()->getConfig() );
+               $passwordFactory = MediaWikiServices::getInstance()->getPasswordFactory();
                try {
                        return $passwordFactory->newFromCiphertext( $password );
                } catch ( PasswordError $ex ) {
@@ -473,6 +470,10 @@ class BotPassword implements IDBAccessObject {
                        return Status::newFatal( 'nosuchuser', $name );
                }
 
+               if ( $user->isLocked() ) {
+                       return Status::newFatal( 'botpasswords-locked' );
+               }
+
                // Throttle
                $throttle = null;
                if ( !empty( $wgPasswordAttemptThrottle ) ) {