From 28eff43b1de94d08677fab98b9c757c52aa0618c Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Wed, 20 Aug 2008 21:27:12 +0000 Subject: [PATCH] Tweak for r29770 (yes, some months after it): If the wiki is read only mode, don't show a "database locked" error if previewing or showing diff, but rather the "normal" action with a warning that the database is currently locked. If the user is trying to save the page, he'll see the preview page instead. Currently, if you are saving or previewing a page while the database is locked, you'll see the "database locked" error with the current text (or no text at all if the page doesn't exist), not your text, this might be confusing. Also added the reason of the lock to the readonlywarning message. --- includes/EditPage.php | 41 +++++++++++++++---------------- languages/messages/MessagesEn.php | 4 ++- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/includes/EditPage.php b/includes/EditPage.php index 614019ed0b..c3baebb4bf 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -122,7 +122,7 @@ class EditPage { if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) { $wgMessageCache->loadAllMessages(); # If this is a system message, get the default text. - $text = wfMsgWeirdKey ( $this->mTitle->getText() ) ; + $text = wfMsgWeirdKey( $this->mTitle->getText() ) ; } else { # If requested, preload some text. $text = $this->getPreloadedText( $preload ); @@ -370,7 +370,7 @@ class EditPage { wfDebug( __METHOD__.": enter\n" ); // this is not an article - $wgOut->setArticleFlag(false); + $wgOut->setArticleFlag( false ); $this->importFormData( $wgRequest ); $this->firsttime = false; @@ -380,20 +380,28 @@ class EditPage { wfProfileOut( __METHOD__ ); return; } - - $wgOut->addScriptFile( 'edit.js' ); if( wfReadOnly() ) { - $this->readOnlyPage( $this->getContent() ); - wfProfileOut( __METHOD__ ); - return; + if( $this->save ){ + // Force preview + $this->save = false; + $this->preview = true; + } elseif( $this->preview || $this->diff ){ + // A warning will be displayed instead + } else { + $this->readOnlyPage( $this->getContent() ); + wfProfileOut( __METHOD__ ); + return; + } } - $permErrors = $this->mTitle->getUserPermissionsErrors('edit', $wgUser); + $wgOut->addScriptFile( 'edit.js' ); + + $permErrors = $this->mTitle->getUserPermissionsErrors( 'edit', $wgUser ); if( !$this->mTitle->exists() ) { $permErrors = array_merge( $permErrors, - wfArrayDiff2( $this->mTitle->getUserPermissionsErrors('create', $wgUser), $permErrors ) ); + wfArrayDiff2( $this->mTitle->getUserPermissionsErrors( 'create', $wgUser ), $permErrors ) ); } # Ignore some permissions errors. @@ -405,15 +413,6 @@ class EditPage { // Don't worry about blocks when previewing/diffing $remove[] = $error; } - - if ($error[0] == 'readonlytext') - { - if ($this->edit) { - $this->formtype = 'preview'; - } elseif ($this->save || $this->preview || $this->diff) { - $remove[] = $error; - } - } } $permErrors = wfArrayDiff2( $permErrors, $remove ); @@ -425,7 +424,7 @@ class EditPage { } else { if ( $this->save ) { $this->formtype = 'save'; - } else if ( $this->preview ) { + } else if( $this->preview ) { $this->formtype = 'preview'; } else if ( $this->diff ) { $this->formtype = 'diff'; @@ -1160,9 +1159,9 @@ class EditPage { } if( wfReadOnly() ) { - $wgOut->addHTML( '
'.wfMsgWikiHTML( 'readonlywarning' ).'
' ); + $wgOut->wrapWikiMsg( "
\n$1\n
", array( 'readonlywarning', wfReadOnlyReason() ) ); } elseif( $wgUser->isAnon() && $this->formtype != 'preview' ) { - $wgOut->addHTML( '
'.wfMsgWikiHTML( 'anoneditwarning' ).'
' ); + $wgOut->wrapWikiMsg( '
$1
', 'anoneditwarning' ); } else { if( $this->isCssJsSubpage && $this->formtype != 'preview' ) { # Check the skin exists diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 4b8f53d675..20a30bcdcb 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -1149,7 +1149,9 @@ Please consider breaking the page into smaller sections.', 'longpageerror' => 'ERROR: The text you have submitted is $1 kilobytes long, which is longer than the maximum of $2 kilobytes. It cannot be saved.', 'readonlywarning' => 'WARNING: The database has been locked for maintenance, so you will not be able to save your edits right now. -You may wish to cut-n-paste the text into a text file and save it for later.', +You may wish to cut-n-paste the text into a text file and save it for later. + +The administrator who locked it offered this explanation: $1', 'protectedpagewarning' => 'WARNING: This page has been locked so that only users with sysop privileges can edit it.', 'semiprotectedpagewarning' => "'''Note:''' This page has been locked so that only registered users can edit it.", 'cascadeprotectedwarning' => "'''Warning:''' This page has been locked so that only users with sysop privileges can edit it, because it is included in the following cascade-protected {{PLURAL:$1|page|pages}}:", -- 2.20.1