Followup r89528, don't use $wgRequest use $this->getMain()->getRequest()->response...
authorSam Reed <reedy@users.mediawiki.org>
Sun, 5 Jun 2011 20:29:47 +0000 (20:29 +0000)
committerSam Reed <reedy@users.mediawiki.org>
Sun, 5 Jun 2011 20:29:47 +0000 (20:29 +0000)
Also fix up a couple of calls to getMain() when we're already in a main class!?

includes/api/ApiFormatBase.php
includes/api/ApiMain.php

index fe00991..2d283b0 100644 (file)
@@ -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 ) {
 ?>
index 0cf1d37..21565bc 100644 (file)
@@ -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 ) {