Display categories on File redirects
authorMatthias Mullie <git@mullie.eu>
Thu, 26 Jan 2017 13:43:19 +0000 (14:43 +0100)
committerMatthias Mullie <git@mullie.eu>
Tue, 4 Jul 2017 09:11:58 +0000 (11:11 +0200)
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

RELEASE-NOTES-1.30
includes/page/Article.php
includes/page/ImagePage.php

index 260276f..c8b746d 100644 (file)
@@ -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
index 656e610..dc4096c 100644 (file)
@@ -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();
index 6a751ac..d37700b 100644 (file)
@@ -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() ) {