-if ( $search = $wgRequest->getText( 'search' ) ) {
- $wgTitle = Title::makeTitle( NS_SPECIAL, "Search" );
- $searchEngine = new SearchEngine( $search );
- if( $wgRequest->getVal( 'fulltext' ) ||
- !is_null( $wgRequest->getVal( 'offset' ) ) ||
- !is_null ($wgRequest->getVal( 'searchx' ) ) ) {
- $searchEngine->showResults();
- } else {
- $searchEngine->goResult();
+wfProfileIn( 'main-action' );
+
+$search = $wgRequest->getText( 'search' );
+if( !$wgDisableInternalSearch && !is_null( $search ) && $search !== '' ) {
+ require_once( 'includes/SpecialSearch.php' );
+ $wgTitle = Title::makeTitle( NS_SPECIAL, 'Search' );
+ wfSpecialSearch();
+} else if( !$wgTitle or $wgTitle->getDBkey() == '' ) {
+ $wgTitle = Title::newFromText( wfMsgForContent( 'badtitle' ) );
+ $wgOut->errorpage( 'badtitle', 'badtitletext' );
+} else if ( $wgTitle->getInterwiki() != '' ) {
+ if( $wgUseLatin1 ) {
+ # Conversion from UTF-8 may truncate or corrupt non-Latin links.
+ # Grab a fresh copy without doing the automated conversion checks.
+ $interwiki = Title::newFromUrl( $_REQUEST['title'] );
+ if( !is_null( $interwiki ) ) $wgTitle = $interwiki;