From fe332e78ac026f26793e528bbe32aa310d6ab364 Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Sun, 5 Jun 2011 20:29:47 +0000 Subject: [PATCH] Followup r89528, don't use $wgRequest use $this->getMain()->getRequest()->response()/$this->getRequest()->response() (the latter when we're already in main!) Also fix up a couple of calls to getMain() when we're already in a main class!? --- includes/api/ApiFormatBase.php | 3 +-- includes/api/ApiMain.php | 13 +++++-------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/includes/api/ApiFormatBase.php b/includes/api/ApiFormatBase.php index fe0099145a..2d283b0301 100644 --- a/includes/api/ApiFormatBase.php +++ b/includes/api/ApiFormatBase.php @@ -146,8 +146,7 @@ abstract class ApiFormatBase extends ApiBase { return; // skip any initialization } - global $wgRequest; - $wgRequest->response()->header( "Content-Type: $mime; charset=utf-8" ); + $this->getMain()->getRequest()->response()->header( "Content-Type: $mime; charset=utf-8" ); if ( $isHtml ) { ?> diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php index 0cf1d374cf..21565bcf0d 100644 --- a/includes/api/ApiMain.php +++ b/includes/api/ApiMain.php @@ -370,8 +370,7 @@ class ApiMain extends ApiBase { // Error results should not be cached $this->setCacheMode( 'private' ); - global $wgRequest; - $response = $wgRequest->response(); + $response = $this->getRequest()->response(); $headerStr = 'MediaWiki-API-Error: ' . $errCode; if ( $e->getCode() === 0 ) { $response->header( $headerStr ); @@ -399,8 +398,7 @@ class ApiMain extends ApiBase { } protected function sendCacheHeaders() { - global $wgRequest; - $response = $wgRequest->response(); + $response = $this->getRequest()->response(); if ( $this->mCacheMode == 'private' ) { $response->header( 'Cache-Control: private' ); @@ -572,7 +570,7 @@ class ApiMain extends ApiBase { $this->dieUsageMsg( array( 'missingparam', 'token' ) ); } else { global $wgUser; - if ( !$wgUser->matchEditToken( $moduleParams['token'], $salt, $this->getMain()->getRequest() ) ) { + if ( !$wgUser->matchEditToken( $moduleParams['token'], $salt, $this->getRequest() ) ) { $this->dieUsageMsg( 'sessionfailure' ); } } @@ -593,8 +591,7 @@ class ApiMain extends ApiBase { $maxLag = $params['maxlag']; list( $host, $lag ) = wfGetLB()->getMaxLag(); if ( $lag > $maxLag ) { - global $wgRequest; - $response = $wgRequest->response(); + $response = $this->getRequest()->response(); $response->header( 'Retry-After: ' . max( intval( $maxLag ), 5 ) ); $response->header( 'X-Database-Lag: ' . intval( $lag ) ); @@ -867,7 +864,7 @@ class ApiMain extends ApiBase { // Get help text from cache if present $key = wfMemcKey( 'apihelp', $this->getModuleName(), SpecialVersion::getVersion( 'nodb' ) . - $this->getMain()->getShowVersions() ); + $this->getShowVersions() ); if ( $wgAPICacheHelpTimeout > 0 ) { $cached = $wgMemc->get( $key ); if ( $cached ) { -- 2.20.1