r85280 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r85279‎ | r85280 | r85281 >
Date:20:43, 3 April 2011
Author:happy-melon
Status:ok
Tags:
Comment:
Expand wfShowMaxLagError() into index.php. It was only being called from here and it's pretty non-portable. Doing so reveals that it's safe to move the declaration of $mediaWiki below the maxlag test, which will fractionally improve performance in that instance (partly compensating for having to parse OutputPage as introduced in r85278).
Modified paths:
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)
  • /trunk/phase3/index.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/GlobalFunctions.php
@@ -3061,26 +3061,6 @@
30623062 }
30633063
30643064 /**
3065 - * Displays a maxlag error
3066 - *
3067 - * @param $host String: server that lags the most
3068 - * @param $lag Integer: maxlag (actual)
3069 - * @param $maxLag Integer: maxlag (requested)
3070 - */
3071 -function wfMaxlagError( $host, $lag, $maxLag ) {
3072 - global $wgShowHostnames;
3073 - header( 'HTTP/1.1 503 Service Unavailable' );
3074 - header( 'Retry-After: ' . max( intval( $maxLag ), 5 ) );
3075 - header( 'X-Database-Lag: ' . intval( $lag ) );
3076 - header( 'Content-Type: text/plain' );
3077 - if( $wgShowHostnames ) {
3078 - echo "Waiting for $host: $lag seconds lagged\n";
3079 - } else {
3080 - echo "Waiting for a database server: $lag seconds lagged\n";
3081 - }
3082 -}
3083 -
3084 -/**
30853065 * Throws a warning that $function is deprecated
30863066 * @param $function String
30873067 * @return null
Index: trunk/phase3/index.php
@@ -37,24 +37,34 @@
3838 * @file
3939 */
4040
41 -# Initialise common code
 41+# Initialise common code. This gives us access to GlobalFunctions, the AutoLoader, and
 42+# the globals $wgRequest, $wgOut, $wgUser, $wgLang and $wgContLang, amongst others; it
 43+# does *not* load $wgTitle or $wgArticle
4244 require ( dirname( __FILE__ ) . '/includes/WebStart.php' );
4345
4446 wfProfileIn( 'index.php' );
4547 wfProfileIn( 'index.php-setup' );
4648
47 -# Initialize MediaWiki base class
48 -$mediaWiki = new MediaWiki( $wgRequest, $wgOut );
49 -
5049 $maxLag = $wgRequest->getVal( 'maxlag' );
5150 if ( !is_null( $maxLag ) ) {
5251 list( $host, $lag ) = wfGetLB()->getMaxLag();
5352 if ( $lag > $maxLag ) {
54 - wfMaxlagError( $host, $lag, $maxLag );
 53+ header( 'HTTP/1.1 503 Service Unavailable' );
 54+ header( 'Retry-After: ' . max( intval( $maxLag ), 5 ) );
 55+ header( 'X-Database-Lag: ' . intval( $lag ) );
 56+ header( 'Content-Type: text/plain' );
 57+ if( $wgShowHostnames ) {
 58+ echo "Waiting for $host: $lag seconds lagged\n";
 59+ } else {
 60+ echo "Waiting for a database server: $lag seconds lagged\n";
 61+ }
5562 exit;
5663 }
5764 }
5865
 66+# Initialize MediaWiki base class
 67+$mediaWiki = new MediaWiki( $wgRequest, $wgOut );
 68+
5969 # Set title from request parameters
6070 $wgTitle = $mediaWiki->checkInitialQueries();
6171 $action = $wgRequest->getVal( 'action', 'view' );

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r85278Follow-up to r85240:...happy-melon20:40, 3 April 2011

Status & tagging log