Revert part of Brion's 27627: please don't throw away the child (maxlag) with the...
[lhc/web/wiklou.git] / includes / Wiki.php
index a67ec12..4920ff2 100644 (file)
@@ -60,11 +60,7 @@ class MediaWiki {
                global $wgLoadBalancer;
                list( $host, $lag ) = $wgLoadBalancer->getMaxLag();
                if ( $lag > $maxLag ) {
-                       header( 'HTTP/1.1 503 Service Unavailable' );
-                       header( 'Retry-After: ' . max( intval( $maxLag ), 5 ) );
-                       header( 'X-Database-Lag: ' . intval( $lag ) );
-                       header( 'Content-Type: text/plain' );
-                       echo "Waiting for $host: $lag seconds lagged\n";
+                       wfMaxlagError( $host, $lag, $maxLag );
                        return false;
                } else {
                        return true;
@@ -98,7 +94,8 @@ class MediaWiki {
                                $lang->findVariantLink( $title, $ret );
 
                }
-               if ( $ret->getNamespace() != -1 && $oldid = $request->getInt( 'oldid' ) ) {
+               if ( ( $oldid = $request->getInt( 'oldid' ) )
+                       && ( is_null( $ret ) || $ret->getNamespace() != NS_SPECIAL ) ) {
                        // Allow oldid to override a changed or missing title.
                        $rev = Revision::newFromId( $oldid );
                        if( $rev ) {
@@ -113,16 +110,14 @@ class MediaWiki {
         */
        function preliminaryChecks ( &$title, &$output, $request ) {
 
-               # Debug statement for user levels
-               // print_r($wgUser);
-
-               $search = $request->getText( 'search' );
-               if( !is_null( $search ) && $search !== '' ) {
+               if( $request->getCheck( 'search' ) ) {
                        // Compatibility with old search URLs which didn't use Special:Search
+                       // Just check for presence here, so blank requests still
+                       // show the search page when using ugly URLs (bug 8054).
+                       
                        // Do this above the read whitelist check for security...
                        $title = SpecialPage::getTitleFor( 'Search' );
                }
-               $this->setVal( 'Search', $search );
 
                # If the user is not logged in, the Namespace:title of the article must be in
                # the Read array in order for the user to see it. (We have to check here to
@@ -142,13 +137,8 @@ class MediaWiki {
                global $wgRequest;
                wfProfileIn( 'MediaWiki::initializeSpecialCases' );
 
-               $search = $this->getVal('Search');
                $action = $this->getVal('Action');
-               if( !$this->getVal('DisableInternalSearch') && !is_null( $search ) && $search !== '' ) {
-                       require_once( 'includes/SpecialSearch.php' );
-                       $title = SpecialPage::getTitleFor( 'Search' );
-                       wfSpecialSearch();
-               } else if( !$title or $title->getDBkey() == '' ) {
+               if( !$title or $title->getDBkey() == '' ) {
                        $title = SpecialPage::getTitleFor( 'Badtitle' );
                        # Die now before we mess up $wgArticle and the skin stops working
                        throw new ErrorPageError( 'badtitle', 'badtitletext' );
@@ -216,7 +206,7 @@ class MediaWiki {
         * @param Title $title
         * @return Article
         */
-       function articleFromTitle( $title ) {
+       static function articleFromTitle( $title ) {
                $article = null;
                wfRunHooks('ArticleFromTitle', array( &$title, &$article ) );
                if ( $article ) {
@@ -254,7 +244,7 @@ class MediaWiki {
                $article = $this->articleFromTitle( $title );
 
                // Namespace might change when using redirects
-               if( $action == 'view' && !$request->getVal( 'oldid' ) &&
+               if( ( $action == 'view' || $action == 'render' ) && !$request->getVal( 'oldid' ) &&
                                                $request->getVal( 'redirect' ) != 'no' ) {
 
                        $dbr = wfGetDB(DB_SLAVE);
@@ -373,6 +363,11 @@ class MediaWiki {
 
                wfProfileIn( 'MediaWiki::performAction' );
 
+               if ( !wfRunHooks('MediaWikiPerformAction', array($output, $article, $title, $user, $request)) ) {
+                       wfProfileOut( 'MediaWiki::performAction' );
+                       return;
+               }
+
                $action = $this->getVal('Action');
                if( in_array( $action, $this->getVal('DisabledActions',array()) ) ) {
                        /* No such action; this will switch to the default case */