r89531 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89530‎ | r89531 | r89532 >
Date:20:29, 5 June 2011
Author:reedy
Status:ok
Tags:
Comment:
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!?
Modified paths:
  • /trunk/phase3/includes/api/ApiFormatBase.php (modified) (history)
  • /trunk/phase3/includes/api/ApiMain.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiFormatBase.php
@@ -146,8 +146,7 @@
147147 return; // skip any initialization
148148 }
149149
150 - global $wgRequest;
151 - $wgRequest->response()->header( "Content-Type: $mime; charset=utf-8" );
 150+ $this->getMain()->getRequest()->response()->header( "Content-Type: $mime; charset=utf-8" );
152151
153152 if ( $isHtml ) {
154153 ?>
Index: trunk/phase3/includes/api/ApiMain.php
@@ -370,8 +370,7 @@
371371 // Error results should not be cached
372372 $this->setCacheMode( 'private' );
373373
374 - global $wgRequest;
375 - $response = $wgRequest->response();
 374+ $response = $this->getRequest()->response();
376375 $headerStr = 'MediaWiki-API-Error: ' . $errCode;
377376 if ( $e->getCode() === 0 ) {
378377 $response->header( $headerStr );
@@ -399,8 +398,7 @@
400399 }
401400
402401 protected function sendCacheHeaders() {
403 - global $wgRequest;
404 - $response = $wgRequest->response();
 402+ $response = $this->getRequest()->response();
405403
406404 if ( $this->mCacheMode == 'private' ) {
407405 $response->header( 'Cache-Control: private' );
@@ -572,7 +570,7 @@
573571 $this->dieUsageMsg( array( 'missingparam', 'token' ) );
574572 } else {
575573 global $wgUser;
576 - if ( !$wgUser->matchEditToken( $moduleParams['token'], $salt, $this->getMain()->getRequest() ) ) {
 574+ if ( !$wgUser->matchEditToken( $moduleParams['token'], $salt, $this->getRequest() ) ) {
577575 $this->dieUsageMsg( 'sessionfailure' );
578576 }
579577 }
@@ -593,8 +591,7 @@
594592 $maxLag = $params['maxlag'];
595593 list( $host, $lag ) = wfGetLB()->getMaxLag();
596594 if ( $lag > $maxLag ) {
597 - global $wgRequest;
598 - $response = $wgRequest->response();
 595+ $response = $this->getRequest()->response();
599596
600597 $response->header( 'Retry-After: ' . max( intval( $maxLag ), 5 ) );
601598 $response->header( 'X-Database-Lag: ' . intval( $lag ) );
@@ -867,7 +864,7 @@
868865 // Get help text from cache if present
869866 $key = wfMemcKey( 'apihelp', $this->getModuleName(),
870867 SpecialVersion::getVersion( 'nodb' ) .
871 - $this->getMain()->getShowVersions() );
 868+ $this->getShowVersions() );
872869 if ( $wgAPICacheHelpTimeout > 0 ) {
873870 $cached = $wgMemc->get( $key );
874871 if ( $cached ) {

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r89528* (bug 22179) Internal use of API (FauxRequest) results in HTTP headers being...reedy19:51, 5 June 2011

Status & tagging log