From ddf879fccfb0d5931c2aacf06dcc8a39c8aa1219 Mon Sep 17 00:00:00 2001 From: Bryan Tong Minh Date: Sat, 10 May 2008 11:12:53 +0000 Subject: [PATCH] (bug 13943) Fix image redirect behaviour on image pages: * Confused redirect source with target * Don't check for article existence if the target is a foreign image page --- RELEASE-NOTES | 1 + includes/ImagePage.php | 12 ++++++++++-- includes/Wiki.php | 5 ++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 16dc47f61d..1093931cda 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -268,6 +268,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 12644) Template list on edit page now sorted on preview * (bug 14058) Support pipe trick for namespaces and interwikis with "-" * Message name filter on Special:Allmessages now case-insensitive +* (bug 13943) Fix image redirect behaviour on image pages === API changes in 1.13 === diff --git a/includes/ImagePage.php b/includes/ImagePage.php index 764a7a747c..1582359cb0 100644 --- a/includes/ImagePage.php +++ b/includes/ImagePage.php @@ -111,14 +111,18 @@ class ImagePage extends Article { // Foreign image page $from = $this->img->getRedirected(); - return $this->mRedirectTarget = Title::makeTitle( NS_IMAGE, $from ); + $to = $this->img->getName(); + if ($from == $to) return null; + return $this->mRedirectTarget = Title::makeTitle( NS_IMAGE, $to ); } public function followRedirect() { if ( $this->img->isLocal() ) return parent::followRedirect(); $from = $this->img->getRedirected(); - return Title::makeTitle( NS_IMAGE, $from ); + $to = $this->img->getName(); + if ($from == $to) return false; + return Title::makeTitle( NS_IMAGE, $to ); } public function isRedirect( $text = false ) { if ( $this->img->isLocal() ) @@ -126,6 +130,10 @@ class ImagePage extends Article { return (bool)$this->img->getRedirected(); } + + public function isLocal() { + return $this->img->isLocal(); + } /** * Create the TOC diff --git a/includes/Wiki.php b/includes/Wiki.php index 083194fe9d..3c178aaeab 100644 --- a/includes/Wiki.php +++ b/includes/Wiki.php @@ -297,11 +297,14 @@ class MediaWiki { return $target; } } + if( is_object( $target ) ) { // Rewrite environment to redirected article $rarticle = self::articleFromTitle( $target ); $rarticle->loadPageData( $rarticle->pageDataFromTitle( $dbr, $target ) ); - if ( $rarticle->getTitle()->exists() ) { + if ( $rarticle->getTitle()->exists() || + ( $title->getNamespace() == NS_IMAGE && + !$article->isLocal() ) ) { $rarticle->setRedirectedFrom( $title ); $article = $rarticle; $title = $target; -- 2.20.1