r103111 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103110‎ | r103111 | r103112 >
Date:01:19, 15 November 2011
Author:johnduhart
Status:ok (Comments)
Tags:
Comment:
Adding function for checking if the database is in readonly mode
Replacing some code in SpecialPageForm to use these new functions
Modified paths:
  • /trunk/phase3/includes/SpecialPage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SpecialPage.php
@@ -522,6 +522,18 @@
523523 }
524524
525525 /**
 526+ * If the wiki is currently in readonly mode, throws a ReadOnlyError
 527+ *
 528+ * @since 1.19
 529+ * @throws ReadOnlyError
 530+ */
 531+ public function checkReadOnly() {
 532+ if ( wfReadOnly() ) {
 533+ throw new ReadOnlyError;
 534+ }
 535+ }
 536+
 537+ /**
526538 * Sets headers - this should be called from the execute() method of all derived classes!
527539 */
528540 function setHeaders() {
@@ -816,13 +828,11 @@
817829 * @throws ErrorPageError
818830 */
819831 protected function checkExecutePermissions( User $user ) {
820 - if ( $this->requiresWrite() && wfReadOnly() ) {
821 - throw new ReadOnlyError();
 832+ if ( $this->requiresWrite() ) {
 833+ $this->checkReadOnly();
822834 }
823835
824 - if ( !$this->userCanExecute( $this->getUser() ) ) {
825 - throw new PermissionsError( $this->getRestriction() );
826 - }
 836+ $this->checkPermissions();
827837
828838 if ( $this->requiresUnblock() && $user->isBlocked() ) {
829839 $block = $user->mBlock;

Follow-up revisions

RevisionCommit summaryAuthorDate
r103115Updated core SpecialPages to use new functions introduced in r103111 and r103095johnduhart01:34, 15 November 2011

Comments

#Comment by Aaron Schulz (talk | contribs)   02:27, 15 November 2011

By itself, this only saves one line of code per use. Perhaps it would be worth it if was mixed with a function that also checked mRestriction.

Status & tagging log