From ac187d902f235cd6e523fff30b2bcb4765e3e75b Mon Sep 17 00:00:00 2001 From: Daimona Eaytoy Date: Mon, 7 May 2018 20:37:46 +0200 Subject: [PATCH] Use redirect=no in whatLinksHere if the target is a redirect When the user is looking at links to a redirect page and clicks on the link of the page, he would expect to be sent to the page itself, not to the final destination of the redirect. Bug: T189860 Change-Id: I11e663cbce32b4199f16df6ed1e9b980630ece7a --- includes/specials/SpecialWhatlinkshere.php | 23 +++++++++++++++++++--- languages/i18n/en.json | 6 +++--- languages/i18n/qqq.json | 6 +++--- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/includes/specials/SpecialWhatlinkshere.php b/includes/specials/SpecialWhatlinkshere.php index 3080fbfedb..5677ac802b 100644 --- a/includes/specials/SpecialWhatlinkshere.php +++ b/includes/specials/SpecialWhatlinkshere.php @@ -208,8 +208,16 @@ class SpecialWhatLinksHere extends IncludableSpecialPage { if ( $hidelinks || $hidetrans || $hideredirs || $hideimages ) { $out->addHTML( $this->getFilterPanel() ); } - $errMsg = is_int( $namespace ) ? 'nolinkshere-ns' : 'nolinkshere'; - $out->addWikiMsg( $errMsg, $this->target->getPrefixedText() ); + $msgKey = is_int( $namespace ) ? 'nolinkshere-ns-2' : 'nolinkshere-2'; + $link = $this->getLinkRenderer()->makeKnownLink( + $this->target, + null, + [], + $this->target->isRedirect() ? [ 'redirect' => 'no' ] : [] + ); + + $errMsg = $this->msg( $msgKey )->rawParams( $link )->parseAsBlock(); + $out->addHTML( $errMsg ); $out->setStatusCode( 404 ); } } @@ -273,7 +281,16 @@ class SpecialWhatLinksHere extends IncludableSpecialPage { if ( !$this->including() ) { $out->addHTML( $this->whatlinkshereForm() ); $out->addHTML( $this->getFilterPanel() ); - $out->addWikiMsg( 'linkshere', $this->target->getPrefixedText() ); + + $link = $this->getLinkRenderer()->makeKnownLink( + $this->target, + null, + [], + $this->target->isRedirect() ? [ 'redirect' => 'no' ] : [] + ); + + $msg = $this->msg( 'linkshere-2' )->rawParams( $link )->parseAsBlock(); + $out->addHTML( $msg ); $prevnext = $this->getPrevNext( $prevId, $nextId ); $out->addHTML( $prevnext ); diff --git a/languages/i18n/en.json b/languages/i18n/en.json index 43f9386c79..5a426459c7 100644 --- a/languages/i18n/en.json +++ b/languages/i18n/en.json @@ -2522,9 +2522,9 @@ "whatlinkshere-title": "Pages that link to \"$1\"", "whatlinkshere-summary": "", "whatlinkshere-page": "Page:", - "linkshere": "The following pages link to [[:$1]]:", - "nolinkshere": "No pages link to [[:$1]].", - "nolinkshere-ns": "No pages link to [[:$1]] in the chosen namespace.", + "linkshere-2": "The following pages link to $1:", + "nolinkshere-2": "No pages link to $1.", + "nolinkshere-ns-2": "No pages link to $1 in the chosen namespace.", "isredirect": "redirect page", "istemplate": "transclusion", "isimage": "file link", diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json index 17e26ae75d..30b16dc63f 100644 --- a/languages/i18n/qqq.json +++ b/languages/i18n/qqq.json @@ -2720,9 +2720,9 @@ "whatlinkshere-title": "Title of the special page [[Special:WhatLinksHere]]. This page appears when you click on the 'What links here' button in the toolbox. $1 is the name of the page concerned.", "whatlinkshere-summary": "{{doc-specialpagesummary|whatlinkshere}}", "whatlinkshere-page": "{{Identical|Page}}", - "linkshere": "This message is the header line of the [[Special:WhatLinksHere/$1]] page generated by clicking \"What links here\" in the sidebar toolbox.\n\nIt is followed by a navigation bar built using {{msg-mw|Viewprevnext}}.\n\nParameters:\n* $1 - page title", - "nolinkshere": "Used in [[Special:WhatLinksHere]] if empty. Parameters:\n* $1 - page title\nSee also:\n* {{msg-mw|Nolinkshere-ns}}", - "nolinkshere-ns": "Used in [[Special:WhatLinksHere]] if empty. Parameters:\n* $1 - page title\nSee also:\n* {{msg-mw|Nolinkshere}}", + "linkshere-2": "This message is the header line of the [[Special:WhatLinksHere/$1]] page generated by clicking \"What links here\" in the sidebar toolbox.\n\nIt is followed by a navigation bar built using {{msg-mw|Viewprevnext}}.\n\nParameters:\n* $1 - HTML link to the page.", + "nolinkshere-2": "Used in [[Special:WhatLinksHere]] if empty. Parameters:\n* $1 - HTML link to the page\nSee also:\n* {{msg-mw|Nolinkshere-ns-html}}", + "nolinkshere-ns-2": "Used in [[Special:WhatLinksHere]] if empty. Parameters:\n* $1 - HTML link to the page\nSee also:\n* {{msg-mw|Nolinkshere-html}}", "isredirect": "Displayed in [[Special:WhatLinksHere]] (see [{{fullurl:Special:WhatLinksHere/Project:Translator|hidelinks=1}} Special:WhatLinksHere/Project:Translator] for example).\n\n{{Identical|Redirect page}}", "istemplate": "Means that a page (a template, specifically) is used as {{Page name}}.\nDisplayed in [[Special:WhatLinksHere]] (see [[Special:WhatLinksHere/Template:New portal]] for example).\nIf you are not sure how to translate this term, think of something like \"inclusion\", \"embedding\", or \"insertion\".\n{{Identical|Transclusion}}", "isimage": "This message is displayed on [[Special:WhatLinksHere]] for images. It means that the image is used on the page (as opposed to just being linked to like an non-image page).\n{{Identical|File link}}", -- 2.20.1