From d24a4d7f10a91fd8d12615f99cbb335132737086 Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Thu, 2 Aug 2012 11:20:40 +0200 Subject: [PATCH] Use a better message when a revision is not found. This comes from https://translatewiki.net/wiki/Thread:Support/MediaWiki:Missing-article that asks for a link to the deletion log in the 'missing-article' message. Instead of simply changing that message I replaced it with two news messages 'missing-revision' when trying to view an old revision and 'difference-missing-revision' when showing a difference. This removes the "lego" construction of 'missing-article' with 'missingarticle-rev' and 'missingarticle-diff' submessages. I had to keep current messages since they are still used in extensions. Change-Id: Ibe60c84cfea922a78b3ad22cc48185a109cd617d --- includes/Article.php | 8 ++------ includes/EditPage.php | 5 ++--- includes/diff/DifferenceEngine.php | 26 ++++++++++++++++++-------- languages/messages/MessagesEn.php | 28 ++++++++++++++++++---------- languages/messages/MessagesQqq.php | 11 +++++++++++ maintenance/language/messages.inc | 8 +++++--- 6 files changed, 56 insertions(+), 30 deletions(-) diff --git a/includes/Article.php b/includes/Article.php index 6fc0acdaa4..0e6a5cfa36 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -350,9 +350,7 @@ class Article extends Page { # Pre-fill content with error message so that if something # fails we'll have something telling us what we intended. - $t = $this->getTitle()->getPrefixedText(); - $d = $oldid ? wfMsgExt( 'missingarticle-rev', array( 'escape' ), $oldid ) : ''; - $this->mContent = wfMsgNoTrans( 'missing-article', $t, $d ) ; + $this->mContent = wfMsgNoTrans( 'missing-revision', $oldid ); if ( $oldid ) { # $this->mRevision might already be fetched by getOldIDFromRequest() @@ -1043,9 +1041,7 @@ class Article extends Page { # Show error message $oldid = $this->getOldID(); if ( $oldid ) { - $text = wfMsgNoTrans( 'missing-article', - $this->getTitle()->getPrefixedText(), - wfMsgNoTrans( 'missingarticle-rev', $oldid ) ); + $text = wfMsgNoTrans( 'missing-revision', $oldid ); } elseif ( $this->getTitle()->getNamespace() === NS_MEDIAWIKI ) { // Use the default message text $text = $this->getTitle()->getDefaultMessageText(); diff --git a/includes/EditPage.php b/includes/EditPage.php index f8be535e60..90135df480 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -877,7 +877,7 @@ class EditPage { * * This difers from Article::getContent() that when a missing revision is * encountered the result will be an empty string and not the - * 'missing-article' message. + * 'missing-revision' message. * * @since 1.19 * @return string @@ -2020,8 +2020,7 @@ class EditPage { // Something went wrong $wgOut->wrapWikiMsg( "
\n$1\n
\n", - array( 'missing-article', $this->mTitle->getPrefixedText(), - wfMsgNoTrans( 'missingarticle-rev', $this->oldid ) ) ); + array( 'missing-revision', $this->oldid ) ); } } } diff --git a/includes/diff/DifferenceEngine.php b/includes/diff/DifferenceEngine.php index db3c37c3da..0dbbdd46a8 100644 --- a/includes/diff/DifferenceEngine.php +++ b/includes/diff/DifferenceEngine.php @@ -179,6 +179,22 @@ class DifferenceEngine extends ContextSource { } } + private function showMissingRevision() { + $out = $this->getOutput(); + + $missing = array(); + if ( $this->mOldRev === null ) { + $missing[] = $this->deletedIdMarker( $this->mOldid ); + } + if ( $this->mNewRev === null ) { + $missing[] = $this->deletedIdMarker( $this->mNewid ); + } + + $out->setPageTitle( $this->msg( 'errorpagetitle' ) ); + $out->addWikiMsg( 'difference-missing-revision', + $this->getLanguage()->listToText( $missing ), count( $missing ) ); + } + function showDiffPage( $diffOnly = false ) { wfProfileIn( __METHOD__ ); @@ -188,13 +204,7 @@ class DifferenceEngine extends ContextSource { $out->setRobotPolicy( 'noindex,nofollow' ); if ( !$this->loadRevisionData() ) { - // Sounds like a deleted revision... Let's see what we can do. - $t = $this->getTitle()->getPrefixedText(); - $d = $this->msg( 'missingarticle-diff', - $this->deletedIdMarker( $this->mOldid ), - $this->deletedIdMarker( $this->mNewid ) )->escaped(); - $out->setPageTitle( $this->msg( 'errorpagetitle' ) ); - $out->addWikiMsg( 'missing-article', "$t", "$d" ); + $this->showMissingRevision(); wfProfileOut( __METHOD__ ); return; } @@ -557,7 +567,7 @@ class DifferenceEngine extends ContextSource { function showDiff( $otitle, $ntitle, $notice = '' ) { $diff = $this->getDiff( $otitle, $ntitle, $notice ); if ( $diff === false ) { - $this->getOutput()->addWikiMsg( 'missing-article', "(fixme, bug)", '' ); + $this->showMissingRevision(); return false; } else { $this->showDiffStyle(); diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 1449b26275..bbec29490e 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -1360,6 +1360,10 @@ or [{{fullurl:{{FULLPAGENAME}}|action=edit}} edit this page].', You can [[Special:Search/{{PAGENAME}}|search for this page title]] in other pages, or [{{fullurl:{{#Special:Log}}|page={{FULLPAGENAMEE}}}} search the related logs].', 'noarticletextanon' => '{{int:noarticletext}}', # do not translate or duplicate this message to other languages +'missing-revision' => 'The revision #$1 of the page named "{{PAGENAME}}" does not exist. + +This is usually caused by following an outdated history link to a page that has been deleted. +Details can be found in the [{{fullurl:{{#Special:Log}}/delete|page={{FULLPAGENAMEE}}}} deletion log].', 'userpage-userdoesnotexist' => 'User account "$1" is not registered. Please check if you want to create/edit this page.', 'userpage-userdoesnotexist-view' => 'User account "$1" is not registered.', @@ -1682,16 +1686,20 @@ Note that using the navigation links will reset this column.', 'mergelogpagetext' => 'Below is a list of the most recent merges of one page history into another.', # Diffs -'history-title' => 'Revision history of "$1"', -'difference-title' => 'Difference between revisions of "$1"', -'difference-title-multipage' => 'Difference between pages "$1" and "$2"', -'difference-multipage' => '(Difference between pages)', -'lineno' => 'Line $1:', -'compareselectedversions' => 'Compare selected revisions', -'showhideselectedversions' => 'Show/hide selected revisions', -'editundo' => 'undo', -'diff-multi' => '({{PLURAL:$1|One intermediate revision|$1 intermediate revisions}} by {{PLURAL:$2|one user|$2 users}} not shown)', -'diff-multi-manyusers' => '({{PLURAL:$1|One intermediate revision|$1 intermediate revisions}} by more than $2 {{PLURAL:$2|user|users}} not shown)', +'history-title' => 'Revision history of "$1"', +'difference-title' => 'Difference between revisions of "$1"', +'difference-title-multipage' => 'Difference between pages "$1" and "$2"', +'difference-multipage' => '(Difference between pages)', +'lineno' => 'Line $1:', +'compareselectedversions' => 'Compare selected revisions', +'showhideselectedversions' => 'Show/hide selected revisions', +'editundo' => 'undo', +'diff-multi' => '({{PLURAL:$1|One intermediate revision|$1 intermediate revisions}} by {{PLURAL:$2|one user|$2 users}} not shown)', +'diff-multi-manyusers' => '({{PLURAL:$1|One intermediate revision|$1 intermediate revisions}} by more than $2 {{PLURAL:$2|user|users}} not shown)', +'difference-missing-revision' => '{{PLURAL:$2|One revision|$2 revisions}} of this difference ($1) {{PLURAL:$2|was|were}} not found. + +This is usually caused by following an outdated diff link to a page that has been deleted. +Details can be found in the [{{fullurl:{{#Special:Log}}/delete|page={{FULLPAGENAMEE}}}} deletion log].', # Search results 'search-summary' => '', # do not translate or duplicate this message to other languages diff --git a/languages/messages/MessagesQqq.php b/languages/messages/MessagesQqq.php index 1f263dbba3..463e539155 100644 --- a/languages/messages/MessagesQqq.php +++ b/languages/messages/MessagesQqq.php @@ -983,6 +983,11 @@ Parameters: See also {{msg-mw|Noarticletext-nopermission}}.', 'noarticletext-nopermission' => 'See also {{msg-mw|Noarticletext}}.', +'missing-revision' => 'Text displayed when the requested revision does not exist using a permalink. + +Example: [http://translatewiki.net/w/i.php?title=Project:News&oldid=9999999 Permalink with invalid revision#] + +* $1 is the ID of the missing revision', 'userpage-userdoesnotexist' => 'Error message displayed when trying to edit or create a page or a subpage that belongs to a user who is not registered on the wiki. Parameters: * $1 is a possible username that has not been registered.', 'userpage-userdoesnotexist-view' => 'Shown in user pages of non existing users. See for example [http://translatewiki.net/wiki/User:Foo User:Foo]. Parameters: @@ -1306,6 +1311,12 @@ This message has sometimes a tooltip {{msg-mw|tooltip-undo}}', 'diff-multi-manyusers' => "This message appears in the revision history of a page when comparing two versions which aren't consecutive, and the intermediate revisions have been edited by more than 100 users. Parameters: * $1 is the number of revisions, will always be 101 or more. * $2 is the number of users that were found, which was limited at 100.", +'difference-missing-revision' => 'Text displayed when the requested revision does not exist using a diff link. + +Example: [http://translatewiki.net/w/i.php?title=Project:News&diff=426850&oldid=99999999 Diff with invalid revision#] + +* $1 is the list of missing revisions IDs +* $2 is the number of items in $1', # Search results 'searchresults' => '{{Identical|Search results}}', diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index 30335e8133..44d9a03b69 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -368,9 +368,9 @@ $wgMessageStructure = array( 'readonly', 'enterlockreason', 'readonlytext', - 'missing-article', - 'missingarticle-rev', - 'missingarticle-diff', + 'missing-article', // not used anymore in core, but kept for extensions + 'missingarticle-rev', // not used anymore in core, but kept for extensions + 'missingarticle-diff', // not used anymore in core, but kept for extensions 'readonly_lag', 'internalerror', 'internalerror_info', @@ -616,6 +616,7 @@ $wgMessageStructure = array( 'noarticletext', 'noarticletext-nopermission', 'noarticletextanon', + 'missing-revision', 'userpage-userdoesnotexist', 'userpage-userdoesnotexist-view', 'blocked-notice-logextract', @@ -857,6 +858,7 @@ $wgMessageStructure = array( 'editundo', 'diff-multi', 'diff-multi-manyusers', + 'difference-missing-revision', ), 'search' => array( 'search-summary', -- 2.20.1