X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FMediaWiki.php;h=676108c7577079724461e97f8847149545ccce3d;hb=98f3cfe5c1a41b0dec80be61ad388910313941e5;hp=f3fb15825f1deed7e98aa960810151478f27fce9;hpb=8e655d8dd34c9b5b7857532753b4f1faa7d8571d;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/MediaWiki.php b/includes/MediaWiki.php index f3fb15825f..676108c757 100644 --- a/includes/MediaWiki.php +++ b/includes/MediaWiki.php @@ -203,10 +203,9 @@ class MediaWiki { // curid and oldid request parameters would allow page titles to be enumerated even // when they are not guessable. So we reset the title to Special:Badtitle before the // permissions error is displayed. - // + // The skin mostly uses $this->context->getTitle() these days, but some extensions // still use $wgTitle. - $badTitle = SpecialPage::getTitleFor( 'Badtitle' ); $this->context->setTitle( $badTitle ); $wgTitle = $badTitle; @@ -471,7 +470,6 @@ class MediaWiki { */ public function run() { try { - $this->checkMaxLag(); try { $this->main(); } catch ( ErrorPageError $e ) { @@ -512,6 +510,14 @@ class MediaWiki { $expires = time() + $this->config->get( 'DataCenterUpdateStickTTL' ); $request->response()->setCookie( 'UseDC', 'master', $expires ); } + + // Avoid letting a few seconds of slave lag cause a month of stale data + if ( $factory->laggedSlaveUsed() ) { + $maxAge = $this->config->get( 'CdnMaxageLagged' ); + $this->context->getOutput()->lowerCdnMaxage( $maxAge ); + $request->response()->header( "X-Database-Lagged: true" ); + wfDebugLog( 'replication', "Lagged DB used; CDN cache TTL limited to $maxAge seconds" ); + } } /** @@ -554,33 +560,6 @@ class MediaWiki { } } - /** - * Checks if the request should abort due to a lagged server, - * for given maxlag parameter. - * @return bool - */ - private function checkMaxLag() { - $maxLag = $this->context->getRequest()->getVal( 'maxlag' ); - if ( !is_null( $maxLag ) ) { - list( $host, $lag ) = wfGetLB()->getMaxLag(); - if ( $lag > $maxLag ) { - $resp = $this->context->getRequest()->response(); - $resp->statusHeader( 503 ); - $resp->header( 'Retry-After: ' . max( intval( $maxLag ), 5 ) ); - $resp->header( 'X-Database-Lag: ' . intval( $lag ) ); - $resp->header( 'Content-Type: text/plain' ); - if ( $this->config->get( 'ShowHostnames' ) ) { - echo "Waiting for $host: $lag seconds lagged\n"; - } else { - echo "Waiting for a database server: $lag seconds lagged\n"; - } - - exit; - } - } - return true; - } - private function main() { global $wgTitle, $wgTrxProfilerLimits; @@ -649,7 +628,7 @@ class MediaWiki { // redirecting to HTTPS. It's likely such a request is going // to fail due to post data being lost, but let's try anyway // and just log the instance. - // + // @todo FIXME: See if we could issue a 307 or 308 here, need // to see how clients (automated & browser) behave when we do wfDebugLog( 'RedirectedPosts', "Redirected from HTTP to HTTPS: $oldUrl" ); @@ -711,7 +690,7 @@ class MediaWiki { Profiler::instance()->getTransactionProfiler()->resetExpectations(); // Do any deferred jobs - DeferredUpdates::doUpdates( 'commit' ); + DeferredUpdates::doUpdates( 'enqueue' ); // Make sure any lazy jobs are pushed JobQueueGroup::pushLazyJobs();