Merge "Add support for PHP7 random_bytes in favor of mcrypt_create_iv"
[lhc/web/wiklou.git] / includes / api / ApiLogin.php
index 723dc33..d64aeb7 100644 (file)
@@ -70,14 +70,7 @@ class ApiLogin extends ApiBase {
                        return;
                }
 
-               try {
-                       $this->requirePostedParameters( [ 'password', 'token' ] );
-               } catch ( ApiUsageException $ex ) {
-                       // Make this a warning for now, upgrade to an error in 1.29.
-                       foreach ( $ex->getStatusValue()->getErrors() as $error ) {
-                               $this->addDeprecation( $error, 'login-params-in-query-string' );
-                       }
-               }
+               $this->requirePostedParameters( [ 'password', 'token' ] );
 
                $params = $this->extractRequestParams();
 
@@ -197,14 +190,19 @@ class ApiLogin extends ApiBase {
                                break;
 
                        case 'Failed':
-                               $result['reason'] = ApiErrorFormatter::stripMarkup(
-                                       $message->useDatabase( false )->inLanguage( 'en' )->text()
-                               );
+                               $errorFormatter = $this->getErrorFormatter();
+                               if ( $errorFormatter instanceof ApiErrorFormatter_BackCompat ) {
+                                       $result['reason'] = ApiErrorFormatter::stripMarkup(
+                                               $message->useDatabase( false )->inLanguage( 'en' )->text()
+                                       );
+                               } else {
+                                       $result['reason'] = $errorFormatter->formatMessage( $message );
+                               }
                                break;
 
                        case 'Aborted':
                                $result['reason'] = 'Authentication requires user interaction, ' .
-                                  'which is not supported by action=login.';
+                                       'which is not supported by action=login.';
                                if ( $this->getConfig()->get( 'EnableBotPasswords' ) ) {
                                        $result['reason'] .= ' To be able to login with action=login, see [[Special:BotPasswords]].';
                                        $result['reason'] .= ' To continue using main-account login, see action=clientlogin.';