bug 511
[lhc/web/wiklou.git] / index.php
index 9f8fa52..755e04a 100644 (file)
--- a/index.php
+++ b/index.php
@@ -25,12 +25,7 @@ OutputPage::setEncodings(); # Not really used yet
 
 # Query string fields
 $action = $wgRequest->getVal( "action", "view" );
-
-if( isset( $_SERVER['PATH_INFO'] ) && $wgUsePathInfo ) {
-       $title = substr( $_SERVER['PATH_INFO'], 1 );
-} else {
-       $title = $wgRequest->getVal( "title" );
-}
+$title = $wgRequest->getVal( "title" );
 
 # Placeholders in case of DB error
 $wgTitle = Title::newFromText( wfMsg( "badtitle" ) );
@@ -61,7 +56,8 @@ if ( !is_null( $wgTitle ) && !$wgTitle->userCanRead() ) {
 }
 
 wfProfileIn( "main-action" );
-if( $search = $wgRequest->getText( 'search' ) ) {
+$search = $wgRequest->getText( 'search' );
+if( !is_null( $search ) && $search !== '' ) {
        require_once( 'SearchEngine.php' );
        $wgTitle = Title::makeTitle( NS_SPECIAL, "Search" );
        $searchEngine = new SearchEngine( $search );
@@ -84,8 +80,9 @@ if( $search = $wgRequest->getText( 'search' ) ) {
                $wgTitle = Title::newFromText( wfMsg( "badtitle" ) );
                $wgOut->errorpage( "badtitle", "badtitletext" );
        }
-} else if ( ( $action == "view" ) && $wgTitle->getPrefixedDBKey() != $title &&
-  !count( array_diff( array_keys( $_GET ), array( 'action', 'title' ) ) ) )
+} 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->redirect( $wgTitle->getFullURL(), '301');