From c3a994a63924228d266182ba8954bb2023b267e5 Mon Sep 17 00:00:00 2001 From: Magnus Manske Date: Wed, 11 Jan 2006 12:56:13 +0000 Subject: [PATCH] Moving more stuff --- includes/Wiki.php | 19 +++++++++++++++++-- index.php | 11 ++--------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/includes/Wiki.php b/includes/Wiki.php index 32ace29074..89c7f6c831 100644 --- a/includes/Wiki.php +++ b/includes/Wiki.php @@ -5,8 +5,16 @@ class MediaWiki { + var $GET ; # Stores the $_GET variables at time of creation, can be changed var $params = array(); + /** + * Constructor + */ + function MediaWiki () { + $this->GET = $_GET ; + } + function setVal( $key, &$value ) { $this->param[strtolower( $key )] = $value; } @@ -22,8 +30,15 @@ class MediaWiki { /** * Initialize the object to be known as $wgArticle for special cases */ - function initializeSpecialCases ( &$title ) { - if ( NS_SPECIAL == $title->getNamespace() ) { + function initializeSpecialCases ( &$title , &$output , $action ) { + if ( ( $action == 'view' ) && + (!isset( $this->GET['title'] ) || $title->getPrefixedDBKey() != $this->GET['title'] ) && + !count( array_diff( array_keys( $this->GET ), array( 'action', 'title' ) ) ) ) + { + /* Redirect to canonical url, make it a 301 to allow caching */ + $output->setSquidMaxage( 1200 ); + $output->redirect( $title->getFullURL(), '301'); + } else if ( NS_SPECIAL == $title->getNamespace() ) { # actions that need to be made when we have a special pages SpecialPage::executePath( $title ); } else { diff --git a/index.php b/index.php index 5500eb5537..f66a375db9 100644 --- a/index.php +++ b/index.php @@ -142,20 +142,13 @@ if( !$wgDisableInternalSearch && !is_null( $search ) && $search !== '' ) { $wgTitle = Title::newFromText( wfMsgForContent( 'badtitle' ) ); $wgOut->errorpage( 'badtitle', 'badtitletext' ); } -} else if ( ( $action == 'view' ) && - (!isset( $_GET['title'] ) || $wgTitle->getPrefixedDBKey() != $_GET['title'] ) && - !count( array_diff( array_keys( $_GET ), array( 'action', 'title' ) ) ) ) -{ - /* redirect to canonical url, make it a 301 to allow caching */ - $wgOut->setSquidMaxage( 1200 ); - $wgOut->redirect( $wgTitle->getFullURL(), '301'); -} else if ( $mediaWiki->initializeSpecialCases( $wgTitle ) ) { +} else if ( $mediaWiki->initializeSpecialCases( $wgTitle , $wgOutput , $action ) ) { # Do nothing, everything was already done by $mediaWiki } else { - $wgArticle =& $mediaWiki->initializeArticle( $wgTitle, $wgRequest, $action ); + $wgArticle = $mediaWiki->initializeArticle( $wgTitle, $wgRequest, $action ); if( in_array( $action, $wgDisabledActions ) ) { $wgOut->errorpage( 'nosuchaction', 'nosuchactiontext' ); -- 2.20.1