(bug 13943) Fix image redirect behaviour on image pages:
authorBryan Tong Minh <btongminh@users.mediawiki.org>
Sat, 10 May 2008 11:12:53 +0000 (11:12 +0000)
committerBryan Tong Minh <btongminh@users.mediawiki.org>
Sat, 10 May 2008 11:12:53 +0000 (11:12 +0000)
* Confused redirect source with target
* Don't check for article existence if the target is a foreign image page

RELEASE-NOTES
includes/ImagePage.php
includes/Wiki.php

index 16dc47f..1093931 100644 (file)
@@ -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 ===
 
index 764a7a7..1582359 100644 (file)
@@ -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
index 083194f..3c178aa 100644 (file)
@@ -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;