}
function checkMaxLag( $maxLag ) {
- global $wgLoadBalancer, $wgShowHostnames;
+ 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' );
- if( $wgShowHostnames ) {
- echo "Waiting for $host: $lag seconds lagged\n";
- } else {
- echo "Waiting for a database server: $lag seconds lagged\n";
- }
+ wfMaxlagError( $host, $lag, $maxLag );
return false;
} else {
return true;
switch( $title->getNamespace() ) {
case NS_IMAGE:
+ $file = wfFindFile( $title );
+ if( $file && $file->getRedirected() ) {
+ return new Article( $title );
+ }
return new ImagePage( $title );
case NS_CATEGORY:
return new CategoryPage( $title );
$this->doJobs();
$loadBalancer->saveMasterPos();
# Now commit any transactions, so that unreported errors after output() don't roll back the whole thing
- $loadBalancer->commitAll();
+ $loadBalancer->commitMasterChanges();
$output->output();
wfProfileOut( 'MediaWiki::finalCleanup' );
}
*/
function doUpdates ( &$updates ) {
wfProfileIn( 'MediaWiki::doUpdates' );
+ /* No need to get master connections in case of empty updates array */
+ if (!$updates) {
+ wfProfileOut('MediaWiki::doUpdates');
+ return;
+ }
+
$dbw = wfGetDB( DB_MASTER );
foreach( $updates as $up ) {
$up->doUpdate();
*/
function restInPeace ( &$loadBalancer ) {
wfLogProfilingData();
- $loadBalancer->closeAll();
wfDebug( "Request ended normally\n" );
}