- # If we got a redirect, follow it (unless we've been told
- # not to by either the function parameter or the query
- if ( !$oldid && !$noredir ) {
- $rt = Title::newFromRedirect( $revision->getText() );
- # process if title object is valid and not special:userlogout
- if ( $rt && ! ( $rt->getNamespace() == NS_SPECIAL && $rt->getText() == 'Userlogout' ) ) {
- # Gotta hand redirects to special pages differently:
- # Fill the HTTP response "Location" header and ignore
- # the rest of the page we're on.
- global $wgDisableHardRedirects;
- if( $globalTitle && !$wgDisableHardRedirects ) {
- global $wgOut;
- if ( $rt->getInterwiki() != '' && $rt->isLocal() ) {
- $source = $this->mTitle->getFullURL( 'redirect=no' );
- $wgOut->redirect( $rt->getFullURL( 'rdfrom=' . urlencode( $source ) ) ) ;
- return false;
- }
- if ( $rt->getNamespace() == NS_SPECIAL ) {
- $wgOut->redirect( $rt->getFullURL() );
- return false;
- }
- }
- if( $rt->getInterwiki() == '' ) {
- $redirData = $this->pageDataFromTitle( $dbr, $rt );
- if( $redirData ) {
- $redirRev = Revision::newFromId( $redirData->page_latest );
- if( !is_null( $redirRev ) ) {
- $this->mRedirectedFrom = $this->mTitle->getPrefixedText();
- $this->mTitle = $rt;
- $data = $redirData;
- $this->loadPageData( $data );
- $revision = $redirRev;
- }
- }
- }
- }
- }
-
- # if the title's different from expected, update...
- if( $globalTitle ) {
- global $wgTitle;
- if( !$this->mTitle->equals( $wgTitle ) ) {
- $wgTitle = $this->mTitle;
- }
- }
-
- # Back to the business at hand...