From: John Du Hart Date: Tue, 15 Nov 2011 01:19:04 +0000 (+0000) Subject: Adding function for checking if the database is in readonly mode X-Git-Tag: 1.31.0-rc.0~26501 X-Git-Url: http://git.cyclocoop.org/%24href?a=commitdiff_plain;h=5b88feca5847c1df1eb9bd2b68f6b789e5785eb1;p=lhc%2Fweb%2Fwiklou.git Adding function for checking if the database is in readonly mode Replacing some code in SpecialPageForm to use these new functions --- diff --git a/includes/SpecialPage.php b/includes/SpecialPage.php index 7d51021677..1c092daf30 100644 --- a/includes/SpecialPage.php +++ b/includes/SpecialPage.php @@ -521,6 +521,18 @@ class SpecialPage { } } + /** + * 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! */ @@ -816,13 +828,11 @@ abstract class FormSpecialPage extends SpecialPage { * @throws ErrorPageError */ protected function checkExecutePermissions( User $user ) { - if ( $this->requiresWrite() && wfReadOnly() ) { - throw new ReadOnlyError(); + if ( $this->requiresWrite() ) { + $this->checkReadOnly(); } - if ( !$this->userCanExecute( $this->getUser() ) ) { - throw new PermissionsError( $this->getRestriction() ); - } + $this->checkPermissions(); if ( $this->requiresUnblock() && $user->isBlocked() ) { $block = $user->mBlock;