Self-revert r105872, there's a deeper issue here
[lhc/web/wiklou.git] / includes / SpecialPage.php
index b033c9d..419c595 100644 (file)
@@ -510,6 +510,29 @@ class SpecialPage {
                throw new PermissionsError( $this->mRestriction );
        }
 
+       /**
+        * Checks if userCanExecute, and if not throws a PermissionsError
+        *
+        * @since 1.19
+        */
+       public function checkPermissions() {
+               if ( !$this->userCanExecute( $this->getUser() ) ) {
+                       $this->displayRestrictionError();
+               }
+       }
+
+       /**
+        * If the wiki is currently in readonly mode, throws a ReadOnlyError
+        *
+        * @since 1.19
+        * @throws ReadOnlyError
+        */
+       public function checkReadOnly() {
+               if ( wfReadOnly() ) {
+                       throw new ReadOnlyError;
+               }
+       }
+
        /**
         * Sets headers - this should be called from the execute() method of all derived classes!
         */
@@ -530,18 +553,15 @@ class SpecialPage {
         */
        function execute( $par ) {
                $this->setHeaders();
+               $this->checkPermissions();
 
-               if ( $this->userCanExecute( $this->getUser() ) ) {
-                       $func = $this->mFunction;
-                       // only load file if the function does not exist
-                       if( !is_callable($func) && $this->mFile ) {
-                               require_once( $this->mFile );
-                       }
-                       $this->outputHeader();
-                       call_user_func( $func, $par, $this );
-               } else {
-                       $this->displayRestrictionError();
+               $func = $this->mFunction;
+               // only load file if the function does not exist
+               if( !is_callable($func) && $this->mFile ) {
+                       require_once( $this->mFile );
                }
+               $this->outputHeader();
+               call_user_func( $func, $par, $this );
        }
 
        /**
@@ -659,11 +679,22 @@ class SpecialPage {
        /**
         * Shortcut to get user's language
         *
+        * @deprecated 1.19 Use getLanguage instead
         * @return Language
         * @since 1.18
         */
        public function getLang() {
-               return $this->getContext()->getLang();
+               return $this->getLanguage();
+       }
+
+       /**
+        * Shortcut to get user's language
+        *
+        * @return Language
+        * @since 1.19
+        */
+       public function getLanguage() {
+               return $this->getContext()->getLanguage();
        }
 
        /**
@@ -808,19 +839,17 @@ abstract class FormSpecialPage extends SpecialPage {
         * @throws ErrorPageError
         */
        protected function checkExecutePermissions( User $user ) {
-               if ( $this->requiresWrite() && wfReadOnly() ) {
-                       throw new ReadOnlyError();
-               }
-
-               if ( !$this->userCanExecute( $this->getUser() ) ) {
-                       throw new PermissionsError( $this->getRestriction() );
-               }
+               $this->checkPermissions();
 
                if ( $this->requiresUnblock() && $user->isBlocked() ) {
                        $block = $user->mBlock;
                        throw new UserBlockedError( $block );
                }
 
+               if ( $this->requiresWrite() ) {
+                       $this->checkReadOnly();
+               }
+
                return true;
        }
 
@@ -963,7 +992,7 @@ abstract class SpecialRedirectToSpecial extends RedirectSpecialPage {
 }
 
 /**
- * ListAdmins --> ListUsers/admin
+ * ListAdmins --> ListUsers/sysop
  */
 class SpecialListAdmins extends SpecialRedirectToSpecial {
        function __construct(){
@@ -972,11 +1001,11 @@ class SpecialListAdmins extends SpecialRedirectToSpecial {
 }
 
 /**
- * ListBots --> ListUsers/admin
+ * ListBots --> ListUsers/bot
  */
 class SpecialListBots extends SpecialRedirectToSpecial {
        function __construct(){
-               parent::__construct( 'Listadmins', 'Listusers', 'bot' );
+               parent::__construct( 'Listbots', 'Listusers', 'bot' );
        }
 }