X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiMain.php;h=84db9edc170f8dd91034c8816c631b18245b0093;hb=4f1390819a8fcd91c0c34449736fff4548032ad3;hp=ccf91dd348afc638d0c28a71711902d1ae8ee30c;hpb=4a4c24208517904e9e5aca123bc494f41960c448;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php index ccf91dd348..84db9edc17 100644 --- a/includes/api/ApiMain.php +++ b/includes/api/ApiMain.php @@ -186,12 +186,12 @@ class ApiMain extends ApiBase { } } - 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; @@ -465,8 +465,6 @@ class ApiMain extends ApiBase { * @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 @@ -494,10 +492,11 @@ class ApiMain extends ApiBase { return false; } + $config = $this->getConfig(); $matchOrigin = self::matchOrigin( $originParam, - $wgCrossSiteAJAXdomains, - $wgCrossSiteAJAXdomainExceptions + $config->get( 'CrossSiteAJAXdomains' ), + $config->get( 'CrossSiteAJAXdomainExceptions' ) ); if ( $matchOrigin ) { @@ -554,29 +553,29 @@ class ApiMain extends ApiBase { } 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 @@ -591,7 +590,7 @@ class ApiMain extends ApiBase { // Send public headers $response->header( $out->getVaryHeader() ); - if ( $wgUseXVO ) { + if ( $useXVO ) { $response->header( $out->getXVO() ); } @@ -644,8 +643,6 @@ class ApiMain extends ApiBase { * @return string */ protected function substituteResultWithError( $e ) { - global $wgShowHostnames; - $result = $this->getResult(); // Printer may not be initialized if the extractRequestParams() fails for the main module @@ -669,6 +666,8 @@ class ApiMain extends ApiBase { // 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(); @@ -678,9 +677,8 @@ class ApiMain extends ApiBase { 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()}"; @@ -692,7 +690,7 @@ class ApiMain extends ApiBase { ); ApiResult::setContent( $errMessage, - $wgShowExceptionDetails ? "\n\n{$e->getTraceAsString()}\n\n" : '' + $config->get( 'ShowExceptionDetails' ) ? "\n\n{$e->getTraceAsString()}\n\n" : '' ); } @@ -707,7 +705,7 @@ class ApiMain extends ApiBase { 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() ); } @@ -725,8 +723,6 @@ class ApiMain extends ApiBase { * @return array */ protected function setupExecuteAction() { - global $wgShowHostnames; - // First add the id to the top element $result = $this->getResult(); $requestid = $this->getParameter( 'requestid' ); @@ -734,7 +730,7 @@ class ApiMain extends ApiBase { $result->addValue( null, 'requestid', $requestid ); } - if ( $wgShowHostnames ) { + if ( $this->getConfig()->get( 'ShowHostnames' ) ) { $servedby = $this->getParameter( 'servedby' ); if ( $servedby ) { $result->addValue( null, 'servedby', wfHostName() ); @@ -792,7 +788,6 @@ class ApiMain extends ApiBase { 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 ) { @@ -801,7 +796,7 @@ class ApiMain extends ApiBase { $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' ); } @@ -957,7 +952,7 @@ class ApiMain extends ApiBase { /** * 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; @@ -1057,8 +1052,7 @@ class ApiMain extends ApiBase { * @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' ); } @@ -1257,20 +1251,22 @@ class ApiMain extends ApiBase { * @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;