From: Matthias Mullie Date: Thu, 26 Jan 2017 13:43:19 +0000 (+0100) Subject: Display categories on File redirects X-Git-Tag: 1.31.0-rc.0~2802 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/supprimer.php?a=commitdiff_plain;h=6a8fcd3a7e387d6172a540b87f7ccae0a39e45f6;p=lhc%2Fweb%2Fwiklou.git Display categories on File redirects This NS_FILE-specific redirect logic was introduced in 2008, in 3c9536652a3b27ec97cb2e3f046c5e98849c58a4. mTitle, as referenced to in the comments, no longer exists. Article also no longer creates redirects in there, that’s now in WikitextContent::fillParserOutput. The original commit message describes that this was introduced to be able to display redirects to foreign file repos. A lot has changed in how that works since 2008, too :) Back to the present: for redirects to foreign repos, `$this->mPage->getFile()->getRedirected()` seems to always return `null` (a placeholder object is created when the thing doesn’t exist), so this this foreign repo-specific bit of code is bypassed anyway. For local redirects, Article::view seems to be working just fine. By using Article::view, Categories used on file redirect pages will now actually be displayed too. And we can get rid of the otherwise no longer used Article::viewRedirect. Bug: T29857 Change-Id: Icb02f3af32d10870f58d945cb06a84b3ba1305d3 --- diff --git a/RELEASE-NOTES-1.30 b/RELEASE-NOTES-1.30 index 260276fdff..c8b746d5fa 100644 --- a/RELEASE-NOTES-1.30 +++ b/RELEASE-NOTES-1.30 @@ -126,6 +126,7 @@ changes to languages because of Phabricator reports. ParserOptions that would pollute the parser cache. Callers should use WikiPage::makeParserOptions() to create the ParserOptions object and only change options that affect the parser cache key. +* Article::viewRedirect() is deprecated. == Compatibility == MediaWiki 1.30 requires PHP 5.5.9 or later. There is experimental support for diff --git a/includes/page/Article.php b/includes/page/Article.php index 656e6102ad..dc4096c438 100644 --- a/includes/page/Article.php +++ b/includes/page/Article.php @@ -1433,6 +1433,8 @@ class Article implements Page { * @param bool $appendSubtitle [optional] * @param bool $forceKnown Should the image be shown as a bluelink regardless of existence? * @return string Containing HTML with redirect link + * + * @deprecated since 1.30 */ public function viewRedirect( $target, $appendSubtitle = true, $forceKnown = false ) { $lang = $this->getTitle()->getPageLanguage(); diff --git a/includes/page/ImagePage.php b/includes/page/ImagePage.php index 6a751ac706..d37700b58d 100644 --- a/includes/page/ImagePage.php +++ b/includes/page/ImagePage.php @@ -115,23 +115,11 @@ class ImagePage extends Article { if ( $this->getTitle()->getNamespace() == NS_FILE && $this->mPage->getFile()->getRedirected() ) { if ( $this->getTitle()->getDBkey() == $this->mPage->getFile()->getName() || $diff !== null ) { - // mTitle is the same as the redirect target so ask Article - // to perform the redirect for us. $request->setVal( 'diffonly', 'true' ); - parent::view(); - return; - } else { - // mTitle is not the same as the redirect target so it is - // probably the redirect page itself. Fake the redirect symbol - $out->setPageTitle( $this->getTitle()->getPrefixedText() ); - $out->addHTML( $this->viewRedirect( - Title::makeTitle( NS_FILE, $this->mPage->getFile()->getName() ), - /* $appendSubtitle */ true, - /* $forceKnown */ true ) - ); - $this->mPage->doViewUpdates( $this->getContext()->getUser(), $this->getOldID() ); - return; } + + parent::view(); + return; } if ( $wgShowEXIF && $this->displayImg->exists() ) {