From: John Du Hart Date: Tue, 15 Nov 2011 01:34:19 +0000 (+0000) Subject: Updated core SpecialPages to use new functions introduced in r103111 and r103095 X-Git-Tag: 1.31.0-rc.0~26500 X-Git-Url: http://git.cyclocoop.org/%40spipnet%40?a=commitdiff_plain;h=b39e54f407b95ab137079de7492aea6b4c81ff58;p=lhc%2Fweb%2Fwiklou.git Updated core SpecialPages to use new functions introduced in r103111 and r103095 --- diff --git a/includes/specials/SpecialBlock.php b/includes/specials/SpecialBlock.php index eedbd470c1..631839f11d 100644 --- a/includes/specials/SpecialBlock.php +++ b/includes/specials/SpecialBlock.php @@ -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 diff --git a/includes/specials/SpecialChangeEmail.php b/includes/specials/SpecialChangeEmail.php index 45cff6aad4..2e606ecc3b 100644 --- a/includes/specials/SpecialChangeEmail.php +++ b/includes/specials/SpecialChangeEmail.php @@ -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' ); diff --git a/includes/specials/SpecialChangePassword.php b/includes/specials/SpecialChangePassword.php index 2e2be557ef..dc43e9a701 100644 --- a/includes/specials/SpecialChangePassword.php +++ b/includes/specials/SpecialChangePassword.php @@ -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' ) ); diff --git a/includes/specials/SpecialConfirmemail.php b/includes/specials/SpecialConfirmemail.php index 70bbfe39b6..857cdcfeb8 100644 --- a/includes/specials/SpecialConfirmemail.php +++ b/includes/specials/SpecialConfirmemail.php @@ -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() ) { diff --git a/includes/specials/SpecialEditWatchlist.php b/includes/specials/SpecialEditWatchlist.php index 89ddbb08b6..54b175444c 100644 --- a/includes/specials/SpecialEditWatchlist.php +++ b/includes/specials/SpecialEditWatchlist.php @@ -47,9 +47,7 @@ class SpecialEditWatchlist extends UnlistedSpecialPage { return; } - if ( wfReadOnly() ) { - throw new ReadOnlyError; - } + $this->checkPermissions(); $this->outputHeader(); diff --git a/includes/specials/SpecialImport.php b/includes/specials/SpecialImport.php index 76577f4be0..0bc0f8f56a 100644 --- a/includes/specials/SpecialImport.php +++ b/includes/specials/SpecialImport.php @@ -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' ) { diff --git a/includes/specials/SpecialMergeHistory.php b/includes/specials/SpecialMergeHistory.php index 658680aeb5..ac01ad27fa 100644 --- a/includes/specials/SpecialMergeHistory.php +++ b/includes/specials/SpecialMergeHistory.php @@ -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(); diff --git a/includes/specials/SpecialMovepage.php b/includes/specials/SpecialMovepage.php index f7eddcc138..49cf0d814b 100644 --- a/includes/specials/SpecialMovepage.php +++ b/includes/specials/SpecialMovepage.php @@ -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(); diff --git a/includes/specials/SpecialPreferences.php b/includes/specials/SpecialPreferences.php index 38ae2239e0..946112bf74 100644 --- a/includes/specials/SpecialPreferences.php +++ b/includes/specials/SpecialPreferences.php @@ -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(); diff --git a/includes/specials/SpecialRevisiondelete.php b/includes/specials/SpecialRevisiondelete.php index 28aa3587b7..b8d0636a2a 100644 --- a/includes/specials/SpecialRevisiondelete.php +++ b/includes/specials/SpecialRevisiondelete.php @@ -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(); diff --git a/includes/specials/SpecialUnblock.php b/includes/specials/SpecialUnblock.php index e38d1c2548..479443097a 100644 --- a/includes/specials/SpecialUnblock.php +++ b/includes/specials/SpecialUnblock.php @@ -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 ); diff --git a/includes/specials/SpecialUndelete.php b/includes/specials/SpecialUndelete.php index 4bf404fb86..d130b131ed 100644 --- a/includes/specials/SpecialUndelete.php +++ b/includes/specials/SpecialUndelete.php @@ -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(); diff --git a/includes/specials/SpecialUpload.php b/includes/specials/SpecialUpload.php index 906ac2c811..2331314487 100644 --- a/includes/specials/SpecialUpload.php +++ b/includes/specials/SpecialUpload.php @@ -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(); diff --git a/includes/specials/SpecialUploadStash.php b/includes/specials/SpecialUploadStash.php index 8901fa5a73..5d353f1c3f 100644 --- a/includes/specials/SpecialUploadStash.php +++ b/includes/specials/SpecialUploadStash.php @@ -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(); diff --git a/includes/specials/SpecialUserrights.php b/includes/specials/SpecialUserrights.php index 048ed6c8d3..2be6e98abe 100644 --- a/includes/specials/SpecialUserrights.php +++ b/includes/specials/SpecialUserrights.php @@ -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();