From ec1f42a1e962984171b7997caa978ee3c5a19085 Mon Sep 17 00:00:00 2001 From: Bryan Tong Minh Date: Fri, 9 May 2008 10:42:49 +0000 Subject: [PATCH] * Use getters where appropriate * Fix following foreign file redirects again --- includes/Article.php | 5 +++++ includes/ImagePage.php | 6 ++++++ includes/Wiki.php | 6 +++--- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/includes/Article.php b/includes/Article.php index 8d9e5ea24e..d4aa897f65 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -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 { diff --git a/includes/ImagePage.php b/includes/ImagePage.php index bbc1745c33..0ba21985ea 100644 --- a/includes/ImagePage.php +++ b/includes/ImagePage.php @@ -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 diff --git a/includes/Wiki.php b/includes/Wiki.php index 2241c22559..083194fe9d 100644 --- a/includes/Wiki.php +++ b/includes/Wiki.php @@ -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__ ); -- 2.20.1