Expand wfShowMaxLagError() into index.php. It was only being called from here and...
authorHappy-melon <happy-melon@users.mediawiki.org>
Sun, 3 Apr 2011 20:43:50 +0000 (20:43 +0000)
committerHappy-melon <happy-melon@users.mediawiki.org>
Sun, 3 Apr 2011 20:43:50 +0000 (20:43 +0000)
includes/GlobalFunctions.php
index.php

index 9dbbe54..8520ec8 100644 (file)
@@ -3060,26 +3060,6 @@ function wfGetNull() {
                : '/dev/null';
 }
 
-/**
- * Displays a maxlag error
- *
- * @param $host String: server that lags the most
- * @param $lag Integer: maxlag (actual)
- * @param $maxLag Integer: maxlag (requested)
- */
-function wfMaxlagError( $host, $lag, $maxLag ) {
-       global $wgShowHostnames;
-       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' );
-       if( $wgShowHostnames ) {
-               echo "Waiting for $host: $lag seconds lagged\n";
-       } else {
-               echo "Waiting for a database server: $lag seconds lagged\n";
-       }
-}
-
 /**
  * Throws a warning that $function is deprecated
  * @param $function String
index 7184ebf..38538cf 100644 (file)
--- a/index.php
+++ b/index.php
  * @file
  */
 
-# Initialise common code
+# Initialise common code.  This gives us access to GlobalFunctions, the AutoLoader, and
+# the globals $wgRequest, $wgOut, $wgUser, $wgLang and $wgContLang, amongst others; it
+# does *not* load $wgTitle or $wgArticle
 require ( dirname( __FILE__ ) . '/includes/WebStart.php' );
 
 wfProfileIn( 'index.php' );
 wfProfileIn( 'index.php-setup' );
 
-# Initialize MediaWiki base class
-$mediaWiki = new MediaWiki( $wgRequest, $wgOut );
-
 $maxLag = $wgRequest->getVal( 'maxlag' );
 if ( !is_null( $maxLag ) ) {
        list( $host, $lag ) = wfGetLB()->getMaxLag();
        if ( $lag > $maxLag ) {
-               wfMaxlagError( $host, $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' );
+               if( $wgShowHostnames ) {
+                       echo "Waiting for $host: $lag seconds lagged\n";
+               } else {
+                       echo "Waiting for a database server: $lag seconds lagged\n";
+               }
                exit;
        }
 }
 
+# Initialize MediaWiki base class
+$mediaWiki = new MediaWiki( $wgRequest, $wgOut );
+
 # Set title from request parameters
 $wgTitle = $mediaWiki->checkInitialQueries();
 $action = $wgRequest->getVal( 'action', 'view' );