} 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;
}
}
* @access private
*/
function loadPageData( $data ) {
+ $this->mTitle->mArticleID = $data->page_id;
$this->mTitle->loadRestrictions( $data->page_restrictions );
$this->mTitle->mRestrictionsLoaded = true;
* @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');
// 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' );
}; /* End of class MediaWiki */
-?>
\ No newline at end of file
+?>