Updated core SpecialPages to use new functions introduced in r103111 and r103095
authorJohn Du Hart <johnduhart@users.mediawiki.org>
Tue, 15 Nov 2011 01:34:19 +0000 (01:34 +0000)
committerJohn Du Hart <johnduhart@users.mediawiki.org>
Tue, 15 Nov 2011 01:34:19 +0000 (01:34 +0000)
15 files changed:
includes/specials/SpecialBlock.php
includes/specials/SpecialChangeEmail.php
includes/specials/SpecialChangePassword.php
includes/specials/SpecialConfirmemail.php
includes/specials/SpecialEditWatchlist.php
includes/specials/SpecialImport.php
includes/specials/SpecialMergeHistory.php
includes/specials/SpecialMovepage.php
includes/specials/SpecialPreferences.php
includes/specials/SpecialRevisiondelete.php
includes/specials/SpecialUnblock.php
includes/specials/SpecialUndelete.php
includes/specials/SpecialUpload.php
includes/specials/SpecialUploadStash.php
includes/specials/SpecialUserrights.php

index eedbd47..631839f 100644 (file)
@@ -56,17 +56,8 @@ class SpecialBlock extends SpecialPage {
        }
 
        public function execute( $par ) {
-               # Permission check
-               $user = $this->getUser();
-               if( !$this->userCanExecute( $user ) ) {
-                       $this->displayRestrictionError();
-                       return;
-               }
-
-               # Can't block when the database is locked
-               if( wfReadOnly() ) {
-                       throw new ReadOnlyError;
-               }
+               $this->checkPermissions();
+               $this->checkReadOnly();
 
                # 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
index 45cff6a..2e606ec 100644 (file)
@@ -41,9 +41,7 @@ class SpecialChangeEmail extends UnlistedSpecialPage {
         */
        function execute( $par ) {
                global $wgAuth;
-               if ( wfReadOnly() ) {
-                       throw new ReadOnlyError;
-               }
+               $this->checkReadOnly();
 
                $request = $this->getRequest();
                $this->mPassword = $request->getVal( 'wpPassword' );
index 2e2be55..dc43e9a 100644 (file)
@@ -37,9 +37,7 @@ class SpecialChangePassword extends UnlistedSpecialPage {
        function execute( $par ) {
                global $wgAuth;
 
-               if ( wfReadOnly() ) {
-                       throw new ReadOnlyError;
-               }
+               $this->checkReadOnly();
 
                $request = $this->getRequest();
                $this->mUserName = trim( $request->getVal( 'wpName' ) );
index 70bbfe3..857cdcf 100644 (file)
@@ -46,9 +46,7 @@ class EmailConfirmation extends UnlistedSpecialPage {
        function execute( $code ) {
                $this->setHeaders();
 
-               if ( wfReadOnly() ) {
-                       throw new ReadOnlyError;
-               }
+               $this->checkReadOnly();
 
                if( empty( $code ) ) {
                        if( $this->getUser()->isLoggedIn() ) {
index 89ddbb0..54b1754 100644 (file)
@@ -47,9 +47,7 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
                        return;
                }
 
-               if ( wfReadOnly() ) {
-                       throw new ReadOnlyError;
-               }
+               $this->checkPermissions();
 
                $this->outputHeader();
 
index 76577f4..0bc0f8f 100644 (file)
@@ -78,9 +78,7 @@ class SpecialImport extends SpecialPage {
                        throw new PermissionsError( 'import', $errors );
                }
 
-               if ( wfReadOnly() ) {
-                       throw new ReadOnlyError;
-               }
+               $this->checkReadOnly();
 
                $request = $this->getRequest();
                if ( $request->wasPosted() && $request->getVal( 'action' ) == 'submit' ) {
index 658680a..ac01ad2 100644 (file)
@@ -81,15 +81,8 @@ class SpecialMergeHistory extends SpecialPage {
        }
 
        public function execute( $par ) {
-               $user = $this->getUser();
-               if( !$this->userCanExecute( $user ) ) {
-                       $this->displayRestrictionError();
-                       return;
-               }
-
-               if ( wfReadOnly() ) {
-                       throw new ReadOnlyError;
-               }
+               $this->checkPermissions();
+               $this->checkReadOnly();
 
                $this->loadRequestParams();
 
index f7eddcc..49cf0d8 100644 (file)
@@ -42,10 +42,7 @@ class MovePageForm extends UnlistedSpecialPage {
        }
 
        public function execute( $par ) {
-               # Check for database lock
-               if ( wfReadOnly() ) {
-                       throw new ReadOnlyError;
-               }
+               $this->checkReadOnly();
 
                $this->setHeaders();
                $this->outputHeader();
index 38ae223..946112b 100644 (file)
@@ -42,9 +42,7 @@ class SpecialPreferences extends SpecialPage {
                        $out->showErrorPage( 'prefsnologin', 'prefsnologintext', array( $this->getTitle()->getPrefixedDBkey() ) );
                        return;
                }
-               if ( wfReadOnly() ) {
-                       throw new ReadOnlyError;
-               }
+               $this->checkReadOnly();
 
                if ( $par == 'reset' ) {
                        $this->showResetForm();
index 28aa358..b8d0636 100644 (file)
@@ -111,15 +111,12 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
        }
 
        public function execute( $par ) {
+               $this->checkPermissions();
+               $this->checkReadOnly();
+
                $output = $this->getOutput();
                $user = $this->getUser();
 
-               if( !$user->isAllowed( 'deletedhistory' ) ) {
-                       throw new PermissionsError( 'deletedhistory' );
-               } elseif( wfReadOnly() ) {
-                       throw new ReadOnlyError;
-               }
-
                $this->mIsAllowed = $user->isAllowed('deleterevision'); // for changes
                $this->setHeaders();
                $this->outputHeader();
index e38d1c2..4794430 100644 (file)
@@ -35,16 +35,8 @@ class SpecialUnblock extends SpecialPage {
        }
 
        public function execute( $par ){
-               # Check permissions
-               if( !$this->userCanExecute( $this->getUser() ) ) {
-                       $this->displayRestrictionError();
-                       return;
-               }
-
-               # Check for database lock
-               if( wfReadOnly() ) {
-                       throw new ReadOnlyError;
-               }
+               $this->checkPermissions();
+               $this->checkReadOnly();
 
                list( $this->target, $this->type ) = SpecialBlock::getTargetAndType( $par, $this->getRequest() );
                $this->block = Block::newFromTarget( $this->target );
index 4bf404f..d130b13 100644 (file)
@@ -643,11 +643,8 @@ class SpecialUndelete extends SpecialPage {
        }
 
        function execute( $par ) {
+               $this->checkPermissions();
                $user = $this->getUser();
-               if ( !$this->userCanExecute( $user ) ) {
-                       $this->displayRestrictionError();
-                       return;
-               }
 
                $this->setHeaders();
                $this->outputHeader();
index 906ac2c..2331314 100644 (file)
@@ -161,9 +161,7 @@ class SpecialUpload extends SpecialPage {
                }
 
                # Check whether we actually want to allow changing stuff
-               if( wfReadOnly() ) {
-                       throw new ReadOnlyError;
-               }
+               $this->checkReadOnly();
 
                $this->loadRequest();
 
index 8901fa5..5d353f1 100644 (file)
@@ -45,10 +45,7 @@ class SpecialUploadStash extends UnlistedSpecialPage {
         * @return Boolean: success
         */
        public function execute( $subPage ) {
-               if ( !$this->userCanExecute( $this->getUser() ) ) {
-                       $this->displayRestrictionError();
-                       return false;
-               }
+               $this->checkPermissions();
 
                if ( $subPage === null || $subPage === '' ) {
                        return $this->showUploads();
index 048ed6c..2be6e98 100644 (file)
@@ -105,9 +105,7 @@ class UserrightsPage extends SpecialPage {
                        throw new PermissionsError( null, array( array( $msg ) ) );
                }
 
-               if ( wfReadOnly() ) {
-                       throw new ReadOnlyError;
-               }
+               $this->checkReadOnly();
 
                $this->setHeaders();
                $this->outputHeader();