* Use getters where appropriate
authorBryan Tong Minh <btongminh@users.mediawiki.org>
Fri, 9 May 2008 10:42:49 +0000 (10:42 +0000)
committerBryan Tong Minh <btongminh@users.mediawiki.org>
Fri, 9 May 2008 10:42:49 +0000 (10:42 +0000)
* Fix following foreign file redirects again

includes/Article.php
includes/ImagePage.php
includes/Wiki.php

index 8d9e5ea..d4aa897 100644 (file)
@@ -35,6 +35,7 @@ class Article {
        var $mUser;                             //!<
        var $mUserText;                 //!<
        var $mRedirectTarget;           //!<
+       var $mIsRedirect;
        /**@}}*/
 
        /**
@@ -541,6 +542,10 @@ class Article {
         */
        function isRedirect( $text = false ) {
                if ( $text === false ) {
+                       if ( $this->mDataLoaded ) 
+                               return $this->mIsRedirect;
+                       
+                       // Apparently loadPageData was never called
                        $this->loadContent();
                        $titleObj = Title::newFromRedirect( $this->fetchContent() );
                } else {
index bbc1745..0ba2198 100644 (file)
@@ -120,6 +120,12 @@ class ImagePage extends Article {
                $from = $this->img->getRedirected();
                return Title::makeTitle( NS_IMAGE, $from );             
        }
+       public function isRedirect() {
+               if ( $this->img->isLocal() )
+                       return parent::isRedirect();
+                       
+               return (bool)$this->img->getRedirected();
+       }
 
        /**
         * Create the TOC
index 2241c22..083194f 100644 (file)
@@ -289,7 +289,7 @@ class MediaWiki {
                        $article->loadPageData( $article->pageDataFromTitle( $dbr, $title ) );
 
                        // Follow redirects only for... redirects
-                       if( $article->mIsRedirect ) {
+                       if( $article->isRedirect() ) {
                                $target = $article->followRedirect();
                                if( is_string( $target ) ) {
                                        if( !$this->getVal( 'DisableHardRedirects' ) ) {
@@ -301,14 +301,14 @@ class MediaWiki {
                                        // Rewrite environment to redirected article
                                        $rarticle = self::articleFromTitle( $target );
                                        $rarticle->loadPageData( $rarticle->pageDataFromTitle( $dbr, $target ) );
-                                       if ( $rarticle->mTitle->exists() ) {
+                                       if ( $rarticle->getTitle()->exists() ) {
                                                $rarticle->setRedirectedFrom( $title );
                                                $article = $rarticle;
                                                $title = $target;
                                        }
                                }
                        } else {
-                               $title = $article->mTitle;
+                               $title = $article->getTitle();
                        }
                }
                wfProfileOut( __METHOD__ );