X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiLogout.php;h=6a26e2e3502b4830aaa4d6f8ce07ab903116ef74;hb=e3bd13db0c285f312e31bb1b7271af4628cca80c;hp=b40f5a33b4f3afd9f668572f15f6ad8676c68d21;hpb=a7f35b785943ecf471095e79bc907aa5bbe228ca;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiLogout.php b/includes/api/ApiLogout.php index b40f5a33b4..6a26e2e350 100644 --- a/includes/api/ApiLogout.php +++ b/includes/api/ApiLogout.php @@ -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. @@ -33,8 +35,15 @@ 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 ' . @@ -49,7 +58,7 @@ class ApiLogout extends ApiBase { // Give extensions to do something after user logout $injected_html = ''; - Hooks::run( 'UserLogoutComplete', array( &$user, &$injected_html, $oldName ) ); + Hooks::run( 'UserLogoutComplete', [ &$user, &$injected_html, $oldName ] ); } public function isReadMode() { @@ -57,10 +66,10 @@ class ApiLogout extends ApiBase { } protected function getExamplesMessages() { - return array( + return [ 'action=logout' => 'apihelp-logout-example-logout', - ); + ]; } public function getHelpUrls() {