From a15ed4bc6b056b614296cb839fe8f1e789b31f7d Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Tue, 15 Jan 2008 01:55:48 +0000 Subject: [PATCH] * (bug 12567) Fix for misformatted read-only messages on edit, protect. Also added proper read-only checks to several special pages. Have removed read-only checks from the general user permission framework since it doesn't belong there; user authorization is independent from the database's read-only state, and the way we check and present error conditions is necessarily different. Further, as a detail it was formatting the actual message incorrectly as an inline message when historically it's a big block message with tables and images and stuff. --- RELEASE-NOTES | 3 +++ includes/Article.php | 6 ++++++ includes/EditPage.php | 6 ++++++ includes/ProtectionForm.php | 10 ++++++++-- includes/SpecialImport.php | 5 +++++ includes/SpecialUndelete.php | 4 ++++ includes/SpecialUserrights.php | 6 ++++++ includes/Title.php | 6 ------ 8 files changed, 38 insertions(+), 8 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 5a38b4342e..33c8392557 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -310,6 +310,9 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 12608) Unifying the spelling of getDBkey() in the code. * (bug 12611) Bot flag ignored in recent changes * (bug 12617) Decimal and thousands separators for Romanian +* (bug 12567) Fix for misformatted read-only messages on edit, protect. + Also added proper read-only checks to several special pages. + Have removed read-only checks from the general user permission framework. == Parser changes in 1.12 == diff --git a/includes/Article.php b/includes/Article.php index 37a836ec21..3193d404b5 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -1942,6 +1942,12 @@ class Article { # This code desperately needs to be totally rewritten + # Read-only check... + if ( wfReadOnly() ) { + $wgOut->readOnlyPage(); + return; + } + # Check permissions $permission_errors = $this->mTitle->getUserPermissionsErrors( 'delete', $wgUser ); diff --git a/includes/EditPage.php b/includes/EditPage.php index ddd49e7982..f3d72f5175 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -352,6 +352,12 @@ class EditPage { wfProfileOut( __METHOD__ ); return; } + + if( wfReadOnly() ) { + $wgOut->readOnlyPage( $this->getContent() ); + wfProfileOut( __METHOD__ ); + return; + } $permErrors = $this->mTitle->getUserPermissionsErrors('edit', $wgUser); if( !$this->mTitle->exists() ) { diff --git a/includes/ProtectionForm.php b/includes/ProtectionForm.php index 96fc080deb..950a46319c 100644 --- a/includes/ProtectionForm.php +++ b/includes/ProtectionForm.php @@ -59,7 +59,7 @@ class ProtectionForm { } // The form will be available in read-only to show levels. - $this->disabled = ($this->mPermErrors = $this->mTitle->getUserPermissionsErrors('protect',$wgUser)) != array(); + $this->disabled = wfReadOnly() || ($this->mPermErrors = $this->mTitle->getUserPermissionsErrors('protect',$wgUser)) != array(); $this->disabledAttrib = $this->disabled ? array( 'disabled' => 'disabled' ) : array(); @@ -127,7 +127,13 @@ class ProtectionForm { # Show an appropriate message if the user isn't allowed or able to change # the protection settings at this time if( $this->disabled ) { - $message = $wgOut->formatPermissionsErrorMessage( $this->mPermErrors ); + if( wfReadOnly() ) { + $wgOut->readOnlyPage(); + $message = ''; + } + if( $this->mPermErrors ) { + $message = $wgOut->formatPermissionsErrorMessage( $this->mPermErrors ); + } } else { $message = wfMsg( 'protect-text', wfEscapeWikiText( $this->mTitle->getPrefixedText() ) ); } diff --git a/includes/SpecialImport.php b/includes/SpecialImport.php index 9f4634be6f..d22e2a582a 100644 --- a/includes/SpecialImport.php +++ b/includes/SpecialImport.php @@ -34,6 +34,11 @@ function wfSpecialImport( $page = '' ) { $frompage = ''; $history = true; + if ( wfReadOnly() ) { + $wgOut->readOnlyPage(); + return; + } + if( $wgRequest->wasPosted() && $wgRequest->getVal( 'action' ) == 'submit') { $isUpload = false; $namespace = $wgRequest->getIntOrNull( 'namespace' ); diff --git a/includes/SpecialUndelete.php b/includes/SpecialUndelete.php index a64cfc22bd..954d8a9635 100644 --- a/includes/SpecialUndelete.php +++ b/includes/SpecialUndelete.php @@ -1038,6 +1038,10 @@ class UndeleteForm { function undelete() { global $wgOut, $wgUser; + if ( wfReadOnly() ) { + $wgOut->readOnlyPage(); + return; + } if( !is_null( $this->mTargetObj ) ) { $archive = new PageArchive( $this->mTargetObj ); diff --git a/includes/SpecialUserrights.php b/includes/SpecialUserrights.php index 52ece5447a..8cea7fd8d6 100644 --- a/includes/SpecialUserrights.php +++ b/includes/SpecialUserrights.php @@ -77,6 +77,12 @@ class UserrightsPage extends SpecialPage { return; } + if ( wfReadOnly() ) { + global $wgOut; + $wgOut->readOnlyPage(); + return; + } + $this->outputHeader(); $this->setHeaders(); diff --git a/includes/Title.php b/includes/Title.php index 654de11a11..7ae2a670dd 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -1038,12 +1038,6 @@ class Title { global $wgContLang; global $wgLang; - - if ( wfReadOnly() && $action != 'read' ) { - global $wgReadOnly; - $errors[] = array( 'readonlytext', $wgReadOnly ); - } - global $wgEmailConfirmToEdit, $wgUser; if ( $wgEmailConfirmToEdit && !$user->isEmailConfirmed() ) { -- 2.20.1