From a2f8d2ac740e9dad49f4fc52d424ad6684d06f48 Mon Sep 17 00:00:00 2001 From: Domas Mituzas Date: Sat, 14 Jan 2006 09:58:29 +0000 Subject: [PATCH] Revert brion's revert. And learning a lesson about rebinding references. Ergh, I need to read php docs again :) Removing several & in previous code would have fixed everything, bwah. --- includes/Article.php | 8 +++----- includes/Wiki.php | 43 ++++++++++++++++++++++++++++--------------- 2 files changed, 31 insertions(+), 20 deletions(-) diff --git a/includes/Article.php b/includes/Article.php index 6a1c0e3132..82891fc7bc 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -91,11 +91,8 @@ class Article { } else { return $rt->getFullURL(); } - } elseif( $rt->exists() ) { - // Internal redirects can be handled relatively gracefully. - // We may have to change to another Article subclass, though. - return $rt; - } + } + return $rt; } } @@ -427,6 +424,7 @@ class Article { * @access private */ function loadPageData( $data ) { + $this->mTitle->mArticleID = $data->page_id; $this->mTitle->loadRestrictions( $data->page_restrictions ); $this->mTitle->mRestrictionsLoaded = true; diff --git a/includes/Wiki.php b/includes/Wiki.php index 996a5cf832..7c359b0eef 100644 --- a/includes/Wiki.php +++ b/includes/Wiki.php @@ -195,6 +195,7 @@ class MediaWiki { * @return mixed an Article, or a string to redirect to another URL */ function initializeArticle( $title, $request ) { + global $wgTitle; wfProfileIn( 'MediaWiki::initializeArticle' ); $action = $this->getVal('Action'); @@ -202,21 +203,33 @@ class MediaWiki { // Namespace might change when using redirects if( $action == 'view' && !$request->getVal( 'oldid' ) && $request->getVal( 'redirect' ) != 'no' ) { - $target = $article->followRedirect(); - if( is_string( $target ) ) { - global $wgDisableHardRedirects; - if( !$wgDisableHardRedirects ) { - // we'll need to redirect - return $target; + $dbr=&wfGetDB(DB_SLAVE); + $article->loadPageData($article->pageDataFromTitle($dbr,$title)); + /* Follow redirects only for... redirects */ + if ($article->mIsRedirect) { + $target = $article->followRedirect(); + if( is_string( $target ) ) { + global $wgDisableHardRedirects; + if( !$wgDisableHardRedirects ) { + // we'll need to redirect + return $target; + } } - } - if( is_object( $target ) ) { - // evil globals hack! - global $wgTitle; - $wgTitle = $target; - - $article = $this->articleFromTitle( $target ); - $article->setRedirectedFrom( $title ); + if( is_object( $target ) ) { + // evil globals hack! + /* Rewrite environment to redirected article */ + $rarticle =& new Article($target); + $rarticle->loadPageData($rarticle->pageDataFromTitle($dbr,$target)); + if ($rarticle->mTitle->mArticleID) { + $article =& $rarticle; + $wgTitle = $target; + $article->setRedirectedFrom( $title ); + } else { + $wgTitle = $title; + } + } + } else { + $wgTitle = $article->mTitle; } } wfProfileOut( 'MediaWiki::initializeArticle' ); @@ -363,4 +376,4 @@ class MediaWiki { }; /* End of class MediaWiki */ -?> \ No newline at end of file +?> -- 2.20.1