Merge "Keep headers from jumping when expire interface is shown"
[lhc/web/wiklou.git] / includes / api / ApiLogout.php
index 2c38208..d56c096 100644 (file)
@@ -24,6 +24,8 @@
  * @file
  */
 
+use MediaWiki\Session\BotPasswordSessionProvider;
+
 /**
  * API module to allow users to log out of the wiki. API equivalent of
  * Special:Userlogout.
 class ApiLogout extends ApiBase {
 
        public function execute() {
-               // Make sure it's possible to log out
                $session = MediaWiki\Session\SessionManager::getGlobalSession();
+
+               // Handle bot password logout specially
+               if ( $session->getProvider() instanceof BotPasswordSessionProvider ) {
+                       $session->unpersist();
+                       return;
+               }
+
+               // Make sure it's possible to log out
                if ( !$session->canSetUser() ) {
-                       $this->dieUsage(
-                               'Cannot log out when using ' .
-                                       $session->getProvider()->describe( Language::factory( 'en' ) ),
+                       $this->dieWithError(
+                               [
+                                       'cannotlogoutnow-text',
+                                       $session->getProvider()->describe( $this->getErrorFormatter()->getLanguage() )
+                               ],
                                'cannotlogout'
                        );
                }
@@ -64,6 +75,6 @@ class ApiLogout extends ApiBase {
        }
 
        public function getHelpUrls() {
-               return 'https://www.mediawiki.org/wiki/API:Logout';
+               return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Logout';
        }
 }