* Use standard method to check user permissions
authorAlexandre Emsenhuber <ialex@users.mediawiki.org>
Sat, 16 Jul 2011 19:31:18 +0000 (19:31 +0000)
committerAlexandre Emsenhuber <ialex@users.mediawiki.org>
Sat, 16 Jul 2011 19:31:18 +0000 (19:31 +0000)
* Directly throw an ReadOnlyError instead of calling OutputPage::readOnlyPage()
* In Special:Block: don't let user think the error is temporary if he doesn't have right and the database is locked, instead check permissions first and then the database lock

includes/specials/SpecialBlock.php
includes/specials/SpecialLockdb.php
includes/specials/SpecialUnblock.php
includes/specials/SpecialUnlockdb.php

index f95d61a..a98b1b6 100644 (file)
@@ -59,17 +59,17 @@ class SpecialBlock extends SpecialPage {
        public function execute( $par ) {
                global $wgUser, $wgOut, $wgRequest;
 
-               # Can't block when the database is locked
-               if( wfReadOnly() ) {
-                       $wgOut->readOnlyPage();
-                       return;
-               }
                # Permission check
                if( !$this->userCanExecute( $wgUser ) ) {
-                       $wgOut->permissionRequired( 'block' );
+                       $this->displayRestrictionError();
                        return;
                }
 
+               # Can't block when the database is locked
+               if( wfReadOnly() ) {
+                       throw new ReadOnlyError;
+               }
+
                # Extract variables from the request.  Try not to get into a situation where we
                # need to extract *every* variable from the form just for processing here, but
                # there are legitimate uses for some variables
index 897a9b6..4c70df2 100644 (file)
@@ -38,8 +38,9 @@ class SpecialLockdb extends SpecialPage {
 
                $this->setHeaders();
 
-               if( !$wgUser->isAllowed( 'siteadmin' ) ) {
-                       $wgOut->permissionRequired( 'siteadmin' );
+               # Permission check
+               if( !$this->userCanExecute( $wgUser ) ) {
+                       $this->displayRestrictionError();
                        return;
                }
 
index 8974c5d..0d93958 100644 (file)
@@ -38,13 +38,14 @@ class SpecialUnblock extends SpecialPage {
                global $wgUser, $wgOut, $wgRequest;
 
                # Check permissions
-               if( !$wgUser->isAllowed( 'block' ) ) {
-                       $wgOut->permissionRequired( 'block' );
+               if( !$this->userCanExecute( $wgUser ) ) {
+                       $this->displayRestrictionError();
                        return;
                }
+
                # Check for database lock
                if( wfReadOnly() ) {
-                       $wgOut->readOnlyPage();
+                       throw new ReadOnlyError;
                        return;
                }
 
index 5fbf38a..95ad0bf 100644 (file)
@@ -33,12 +33,13 @@ class SpecialUnlockdb extends SpecialPage {
        }
 
        public function execute( $par ) {
-               global $wgUser, $wgOut, $wgRequest;
+               global $wgUser, $wgRequest;
 
                $this->setHeaders();
 
-               if( !$wgUser->isAllowed( 'siteadmin' ) ) {
-                       $wgOut->permissionRequired( 'siteadmin' );
+               # Permission check
+               if( !$this->userCanExecute( $wgUser ) ) {
+                       $this->displayRestrictionError();
                        return;
                }