}
}
- global $wgAPIModules, $wgAPIFormatModules;
+ $config = $this->getConfig();
$this->mModuleMgr = new ApiModuleManager( $this );
$this->mModuleMgr->addModules( self::$Modules, 'action' );
- $this->mModuleMgr->addModules( $wgAPIModules, 'action' );
+ $this->mModuleMgr->addModules( $config->get( 'APIModules' ), 'action' );
$this->mModuleMgr->addModules( self::$Formats, 'format' );
- $this->mModuleMgr->addModules( $wgAPIFormatModules, 'format' );
+ $this->mModuleMgr->addModules( $config->get( 'APIFormatModules' ), 'format' );
$this->mResult = new ApiResult( $this );
$this->mEnableWrite = $enableWrite;
* @return bool False if the caller should abort (403 case), true otherwise (all other cases)
*/
protected function handleCORS() {
- global $wgCrossSiteAJAXdomains, $wgCrossSiteAJAXdomainExceptions;
-
$originParam = $this->getParameter( 'origin' ); // defaults to null
if ( $originParam === null ) {
// No origin parameter, nothing to do
return false;
}
+ $config = $this->getConfig();
$matchOrigin = self::matchOrigin(
$originParam,
- $wgCrossSiteAJAXdomains,
- $wgCrossSiteAJAXdomainExceptions
+ $config->get( 'CrossSiteAJAXdomains' ),
+ $config->get( 'CrossSiteAJAXdomainExceptions' )
);
if ( $matchOrigin ) {
}
protected function sendCacheHeaders() {
- global $wgUseXVO, $wgVaryOnXFP;
$response = $this->getRequest()->response();
$out = $this->getOutput();
- if ( $wgVaryOnXFP ) {
+ $config = $this->getConfig();
+
+ if ( $config->get( 'VaryOnXFP' ) ) {
$out->addVaryHeader( 'X-Forwarded-Proto' );
}
if ( $this->mCacheMode == 'private' ) {
$response->header( 'Cache-Control: private' );
-
return;
}
+ $useXVO = $config->get( 'UseXVO' );
if ( $this->mCacheMode == 'anon-public-user-private' ) {
$out->addVaryHeader( 'Cookie' );
$response->header( $out->getVaryHeader() );
- if ( $wgUseXVO ) {
+ if ( $useXVO ) {
$response->header( $out->getXVO() );
if ( $out->haveCacheVaryCookies() ) {
// Logged in, mark this request private
$response->header( 'Cache-Control: private' );
-
return;
}
// Logged out, send normal public headers below
// Send public headers
$response->header( $out->getVaryHeader() );
- if ( $wgUseXVO ) {
+ if ( $useXVO ) {
$response->header( $out->getXVO() );
}
* @return string
*/
protected function substituteResultWithError( $e ) {
- global $wgShowHostnames;
-
$result = $this->getResult();
// Printer may not be initialized if the extractRequestParams() fails for the main module
// Update raw mode flag for the selected printer.
$result->setRawMode( $this->mPrinter->getNeedsRawData() );
+ $config = $this->getConfig();
+
if ( $e instanceof UsageException ) {
// User entered incorrect parameters - print usage screen
$errMessage = $e->getMessageArray();
ApiResult::setContent( $errMessage, $this->makeHelpMsg() );
}
} else {
- global $wgShowSQLErrors, $wgShowExceptionDetails;
// Something is seriously wrong
- if ( ( $e instanceof DBQueryError ) && !$wgShowSQLErrors ) {
+ if ( ( $e instanceof DBQueryError ) && !$config->get( 'ShowSQLErrors' ) ) {
$info = 'Database query error';
} else {
$info = "Exception Caught: {$e->getMessage()}";
);
ApiResult::setContent(
$errMessage,
- $wgShowExceptionDetails ? "\n\n{$e->getTraceAsString()}\n\n" : ''
+ $config->get( 'ShowExceptionDetails' ) ? "\n\n{$e->getTraceAsString()}\n\n" : ''
);
}
if ( !is_null( $requestid ) ) {
$result->addValue( null, 'requestid', $requestid );
}
- if ( $wgShowHostnames ) {
+ if ( $config->get( 'ShowHostnames' ) ) {
// servedby is especially useful when debugging errors
$result->addValue( null, 'servedby', wfHostName() );
}
* @return array
*/
protected function setupExecuteAction() {
- global $wgShowHostnames;
-
// First add the id to the top element
$result = $this->getResult();
$requestid = $this->getParameter( 'requestid' );
$result->addValue( null, 'requestid', $requestid );
}
- if ( $wgShowHostnames ) {
+ if ( $this->getConfig()->get( 'ShowHostnames' ) ) {
$servedby = $this->getParameter( 'servedby' );
if ( $servedby ) {
$result->addValue( null, 'servedby', wfHostName() );
protected function checkMaxLag( $module, $params ) {
if ( $module->shouldCheckMaxlag() && isset( $params['maxlag'] ) ) {
// Check for maxlag
- global $wgShowHostnames;
$maxLag = $params['maxlag'];
list( $host, $lag ) = wfGetLB()->getMaxLag();
if ( $lag > $maxLag ) {
$response->header( 'Retry-After: ' . max( intval( $maxLag ), 5 ) );
$response->header( 'X-Database-Lag: ' . intval( $lag ) );
- if ( $wgShowHostnames ) {
+ if ( $this->getConfig()->get( 'ShowHostnames' ) ) {
$this->dieUsage( "Waiting for $host: $lag seconds lagged", 'maxlag' );
}
/**
* Encode a value in a format suitable for a space-separated log line.
* @param string $s
- * return string
+ * @return string
*/
protected function encodeRequestLogValue( $s ) {
static $table;
* @param bool $isError
*/
protected function printResult( $isError ) {
- global $wgDebugAPI;
- if ( $wgDebugAPI !== false ) {
+ if ( $this->getConfig()->get( 'DebugAPI' ) !== false ) {
$this->setWarning( 'SECURITY WARNING: $wgDebugAPI is enabled' );
}
* @return string
*/
public function makeHelpMsg() {
- global $wgMemc, $wgAPICacheHelpTimeout;
+ global $wgMemc;
$this->setHelp();
// Get help text from cache if present
$key = wfMemcKey( 'apihelp', $this->getModuleName(),
str_replace( ' ', '_', SpecialVersion::getVersion( 'nodb' ) ) );
- if ( $wgAPICacheHelpTimeout > 0 ) {
+
+ $cacheHelpTimeout = $this->getConfig()->get( 'APICacheHelpTimeout' );
+ if ( $cacheHelpTimeout > 0 ) {
$cached = $wgMemc->get( $key );
if ( $cached ) {
return $cached;
}
}
$retval = $this->reallyMakeHelpMsg();
- if ( $wgAPICacheHelpTimeout > 0 ) {
- $wgMemc->set( $key, $retval, $wgAPICacheHelpTimeout );
+ if ( $cacheHelpTimeout > 0 ) {
+ $wgMemc->set( $key, $retval, $cacheHelpTimeout );
}
return $retval;