Use a better message when a revision is not found.
authorAlexandre Emsenhuber <ialex.wiki@gmail.com>
Thu, 2 Aug 2012 09:20:40 +0000 (11:20 +0200)
committerAlexandre Emsenhuber <ialex.wiki@gmail.com>
Mon, 6 Aug 2012 08:53:53 +0000 (10:53 +0200)
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
includes/EditPage.php
includes/diff/DifferenceEngine.php
languages/messages/MessagesEn.php
languages/messages/MessagesQqq.php
maintenance/language/messages.inc

index 6fc0acd..0e6a5cf 100644 (file)
@@ -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();
index f8be535..90135df 100644 (file)
@@ -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( "<div class='errorbox'>\n$1\n</div>\n",
-                                               array( 'missing-article', $this->mTitle->getPrefixedText(),
-                                               wfMsgNoTrans( 'missingarticle-rev', $this->oldid ) ) );
+                                               array( 'missing-revision', $this->oldid ) );
                                }
                        }
                }
index db3c37c..0dbbdd4 100644 (file)
@@ -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', "<nowiki>$t</nowiki>", "<span class='plainlinks'>$d</span>" );
+                       $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', "<nowiki>(fixme, bug)</nowiki>", '' );
+                       $this->showMissingRevision();
                        return false;
                } else {
                        $this->showDiffStyle();
index 1449b26..bbec294 100644 (file)
@@ -1360,6 +1360,10 @@ or [{{fullurl:{{FULLPAGENAME}}|action=edit}} edit this page]</span>.',
 You can [[Special:Search/{{PAGENAME}}|search for this page title]] in other pages,
 or <span class="plainlinks">[{{fullurl:{{#Special:Log}}|page={{FULLPAGENAMEE}}}} search the related logs]</span>.',
 '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
index 1f263db..463e539 100644 (file)
@@ -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}}',
index 30335e8..44d9a03 100644 (file)
@@ -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',