Merge "Stop doing $that = $this in includes/libs"
[lhc/web/wiklou.git] / includes / api / ApiLogout.php
index bfdad34..b40f5a3 100644 (file)
 class ApiLogout extends ApiBase {
 
        public function execute() {
+               // Make sure it's possible to log out
+               $session = MediaWiki\Session\SessionManager::getGlobalSession();
+               if ( !$session->canSetUser() ) {
+                       $this->dieUsage(
+                               'Cannot log out when using ' .
+                                       $session->getProvider()->describe( Language::factory( 'en' ) ),
+                               'cannotlogout'
+                       );
+               }
+
                $user = $this->getUser();
                $oldName = $user->getName();
                $user->logout();
 
                // Give extensions to do something after user logout
                $injected_html = '';
-               wfRunHooks( 'UserLogoutComplete', array( &$user, &$injected_html, $oldName ) );
+               Hooks::run( 'UserLogoutComplete', array( &$user, &$injected_html, $oldName ) );
        }
 
        public function isReadMode() {
                return false;
        }
 
-       public function getExamplesMessages() {
+       protected function getExamplesMessages() {
                return array(
                        'action=logout'
                                => 'apihelp-logout-example-logout',