Switch API to use Config classes

Only done where globals are config (so not $wgParser, $wgContLang etc)

Change-Id: Ic39cdd858cfb9096a2bc09618f97e64270d76f13
This commit is contained in:
Reedy 2014-01-24 02:51:11 +00:00
parent 3ee1e6fda2
commit e48ecbc524
37 changed files with 202 additions and 270 deletions

View file

@ -1965,15 +1965,13 @@ abstract class ApiBase extends ContextSource {
* @since 1.21
*/
public function dieUsageMsgOrDebug( $error ) {
global $wgDebugAPI;
if ( $wgDebugAPI !== true ) {
if ( $this->getConfig()->get( 'DebugAPI' ) !== true ) {
$this->dieUsageMsg( $error );
}
if ( is_string( $error ) ) {
$error = array( $error );
}
$parsed = $this->parseMsg( $error );
$this->setWarning( '$wgDebugAPI: ' . $parsed['code'] . ' - ' . $parsed['info'] );
}

View file

@ -90,7 +90,6 @@ class ApiCreateAccount extends ApiBase {
$result = array();
if ( $status->isGood() ) {
// Success!
global $wgEmailAuthentication;
$user = $status->getValue();
if ( $params['language'] ) {
@ -106,7 +105,7 @@ class ApiCreateAccount extends ApiBase {
'createaccount-title',
'createaccount-text'
) );
} elseif ( $wgEmailAuthentication && Sanitizer::validateEmail( $user->getEmail() ) ) {
} elseif ( $this->getConfig()->get( 'EmailAuthentication' ) && Sanitizer::validateEmail( $user->getEmail() ) ) {
// Send out an email authentication message if needed
$status->merge( $user->sendConfirmationMail() );
}
@ -183,8 +182,6 @@ class ApiCreateAccount extends ApiBase {
}
public function getAllowedParams() {
global $wgEmailConfirmToEdit;
return array(
'name' => array(
ApiBase::PARAM_TYPE => 'user',
@ -195,7 +192,7 @@ class ApiCreateAccount extends ApiBase {
'token' => null,
'email' => array(
ApiBase::PARAM_TYPE => 'string',
ApiBase::PARAM_REQUIRED => $wgEmailConfirmToEdit
ApiBase::PARAM_REQUIRED => $this->getConfig()->get( 'EmailConfirmToEdit' ),
),
'realname' => null,
'mailpassword' => array(
@ -293,10 +290,9 @@ class ApiCreateAccount extends ApiBase {
);
// 'passwordtooshort' has parameters. :(
global $wgMinimalPasswordLength;
$errors[] = array(
'code' => 'passwordtooshort',
'info' => wfMessage( 'passwordtooshort', $wgMinimalPasswordLength )
'info' => wfMessage( 'passwordtooshort', $this->getConfig()->get( 'MinimalPasswordLength' ) )
->inLanguage( 'en' )->useDatabase( false )->parse()
);

View file

@ -399,7 +399,6 @@ class ApiEditPage extends ApiBase {
$status = $ep->internalAttemptSave( $result, $user->isAllowed( 'bot' ) && $params['bot'] );
$wgRequest = $oldRequest;
global $wgMaxArticleSize;
switch ( $status->value ) {
case EditPage::AS_HOOK_ERROR:
@ -423,7 +422,7 @@ class ApiEditPage extends ApiBase {
case EditPage::AS_MAX_ARTICLE_SIZE_EXCEEDED:
case EditPage::AS_CONTENT_TOO_BIG:
$this->dieUsageMsg( array( 'contenttoobig', $wgMaxArticleSize ) );
$this->dieUsageMsg( array( 'contenttoobig', $this->getConfig()->get( 'MaxArticleSize' ) ) );
case EditPage::AS_READ_ONLY_PAGE_ANON:
$this->dieUsageMsg( 'noedit-anon' );
@ -499,8 +498,6 @@ class ApiEditPage extends ApiBase {
}
public function getPossibleErrors() {
global $wgMaxArticleSize;
return array_merge( parent::getPossibleErrors(),
$this->getTitleOrPageIdErrorMessage(),
array(
@ -519,7 +516,7 @@ class ApiEditPage extends ApiBase {
array( 'spamdetected', 'spam' ),
array( 'summaryrequired' ),
array( 'blockedtext' ),
array( 'contenttoobig', $wgMaxArticleSize ),
array( 'contenttoobig', $this->getConfig()->get( 'MaxArticleSize' ) ),
array( 'noedit-anon' ),
array( 'noedit' ),
array( 'actionthrottledtext' ),

View file

@ -41,30 +41,29 @@ class ApiFeedContributions extends ApiBase {
public function execute() {
$params = $this->extractRequestParams();
global $wgFeed, $wgFeedClasses, $wgFeedLimit, $wgSitename, $wgLanguageCode;
if ( !$wgFeed ) {
$config = $this->getConfig();
if ( !$config->get( 'Feed' ) ) {
$this->dieUsage( 'Syndication feeds are not available', 'feed-unavailable' );
}
if ( !isset( $wgFeedClasses[$params['feedformat']] ) ) {
$feedClasses = $config->get( 'FeedClasses' );
if ( !isset( $feedClasses[$params['feedformat']] ) ) {
$this->dieUsage( 'Invalid subscription feed type', 'feed-invalid' );
}
global $wgMiserMode;
if ( $params['showsizediff'] && $wgMiserMode ) {
if ( $params['showsizediff'] && $this->getConfig()->get( 'MiserMode' ) ) {
$this->dieUsage( 'Size difference is disabled in Miser Mode', 'sizediffdisabled' );
}
$msg = wfMessage( 'Contributions' )->inContentLanguage()->text();
$feedTitle = $wgSitename . ' - ' . $msg . ' [' . $wgLanguageCode . ']';
$feedTitle = $config->get( 'Sitename' ) . ' - ' . $msg . ' [' . $config->get( 'LanguageCode' ) . ']';
$feedUrl = SpecialPage::getTitleFor( 'Contributions', $params['user'] )->getFullURL();
$target = $params['user'] == 'newbies'
? 'newbies'
: Title::makeTitleSafe( NS_USER, $params['user'] )->getText();
$feed = new $wgFeedClasses[$params['feedformat']] (
$feed = new $feedClasses[$params['feedformat']] (
$feedTitle,
htmlspecialchars( $msg ),
$feedUrl
@ -82,8 +81,9 @@ class ApiFeedContributions extends ApiBase {
'showSizeDiff' => $params['showsizediff'],
) );
if ( $pager->getLimit() > $wgFeedLimit ) {
$pager->setLimit( $wgFeedLimit );
$feedLimit = $this->getConfig()->get( 'FeedLimit' );
if ( $pager->getLimit() > $feedLimit ) {
$pager->setLimit( $feedLimit );
}
$feedItems = array();
@ -159,8 +159,7 @@ class ApiFeedContributions extends ApiBase {
}
public function getAllowedParams() {
global $wgFeedClasses;
$feedFormatNames = array_keys( $wgFeedClasses );
$feedFormatNames = array_keys( $this->getConfig()->get( 'FeedClasses' ) );
return array(
'feedformat' => array(

View file

@ -40,15 +40,16 @@ class ApiFeedRecentChanges extends ApiBase {
* as an RSS/Atom feed.
*/
public function execute() {
global $wgFeed, $wgFeedClasses;
$config = $this->getConfig();
$this->params = $this->extractRequestParams();
if ( !$wgFeed ) {
if ( !$config->get( 'Feed' ) ) {
$this->dieUsage( 'Syndication feeds are not available', 'feed-unavailable' );
}
if ( !isset( $wgFeedClasses[$this->params['feedformat']] ) ) {
$feedClasses = $config->get( 'FeedClasses' );
if ( !isset( $feedClasses[$this->params['feedformat']] ) ) {
$this->dieUsage( 'Invalid subscription feed type', 'feed-invalid' );
}
@ -110,8 +111,8 @@ class ApiFeedRecentChanges extends ApiBase {
}
public function getAllowedParams() {
global $wgFeedClasses, $wgAllowCategorizedRecentChanges, $wgFeedLimit;
$feedFormatNames = array_keys( $wgFeedClasses );
$config = $this->getConfig();
$feedFormatNames = array_keys( $config->get( 'FeedClasses' ) );
$ret = array(
'feedformat' => array(
@ -133,7 +134,7 @@ class ApiFeedRecentChanges extends ApiBase {
'limit' => array(
ApiBase::PARAM_DFLT => 50,
ApiBase::PARAM_MIN => 1,
ApiBase::PARAM_MAX => $wgFeedLimit,
ApiBase::PARAM_MAX => $config->get( 'FeedLimit' ),
ApiBase::PARAM_TYPE => 'integer',
),
'from' => array(
@ -157,7 +158,7 @@ class ApiFeedRecentChanges extends ApiBase {
'showlinkedto' => false,
);
if ( $wgAllowCategorizedRecentChanges ) {
if ( $config->get( 'AllowCategorizedRecentChanges' ) ) {
$ret += array(
'categories' => array(
ApiBase::PARAM_TYPE => 'string',

View file

@ -50,16 +50,16 @@ class ApiFeedWatchlist extends ApiBase {
* Wrap the result as an RSS/Atom feed.
*/
public function execute() {
global $wgFeed, $wgFeedClasses, $wgFeedLimit, $wgSitename, $wgLanguageCode;
$config = $this->getConfig();
$feedClasses = $config->get( 'FeedClasses' );
try {
$params = $this->extractRequestParams();
if ( !$wgFeed ) {
if ( !$config->get( 'Feed' ) ) {
$this->dieUsage( 'Syndication feeds are not available', 'feed-unavailable' );
}
if ( !isset( $wgFeedClasses[$params['feedformat']] ) ) {
if ( !isset( $feedClasses[$params['feedformat']] ) ) {
$this->dieUsage( 'Invalid subscription feed type', 'feed-invalid' );
}
@ -75,7 +75,7 @@ class ApiFeedWatchlist extends ApiBase {
'wlprop' => 'title|user|comment|timestamp|ids',
'wldir' => 'older', // reverse order - from newest to oldest
'wlend' => $endTime, // stop at this time
'wllimit' => min( 50, $wgFeedLimit )
'wllimit' => min( 50, $this->getConfig()->get( 'FeedLimit' ) )
);
if ( $params['wlowner'] !== null ) {
@ -122,10 +122,10 @@ class ApiFeedWatchlist extends ApiBase {
$msg = wfMessage( 'watchlist' )->inContentLanguage()->text();
$feedTitle = $wgSitename . ' - ' . $msg . ' [' . $wgLanguageCode . ']';
$feedTitle = $this->getConfig()->get( 'Sitename' ) . ' - ' . $msg . ' [' . $this->getConfig()->get( 'LanguageCode' ) . ']';
$feedUrl = SpecialPage::getTitleFor( 'Watchlist' )->getFullURL();
$feed = new $wgFeedClasses[$params['feedformat']] (
$feed = new $feedClasses[$params['feedformat']] (
$feedTitle,
htmlspecialchars( $msg ),
$feedUrl
@ -137,14 +137,14 @@ class ApiFeedWatchlist extends ApiBase {
$this->getMain()->setCacheMaxAge( 0 );
// @todo FIXME: Localise brackets
$feedTitle = $wgSitename . ' - Error - ' .
$feedTitle = $this->getConfig()->get( 'Sitename' ) . ' - Error - ' .
wfMessage( 'watchlist' )->inContentLanguage()->text() .
' [' . $wgLanguageCode . ']';
' [' . $this->getConfig()->get( 'LanguageCode' ) . ']';
$feedUrl = SpecialPage::getTitleFor( 'Watchlist' )->getFullURL();
$feedFormat = isset( $params['feedformat'] ) ? $params['feedformat'] : 'rss';
$msg = wfMessage( 'watchlist' )->inContentLanguage()->escaped();
$feed = new $wgFeedClasses[$feedFormat] ( $feedTitle, $msg, $feedUrl );
$feed = new $feedClasses[$feedFormat] ( $feedTitle, $msg, $feedUrl );
if ( $e instanceof UsageException ) {
$errorCode = $e->getCodeString();
@ -205,8 +205,7 @@ class ApiFeedWatchlist extends ApiBase {
}
public function getAllowedParams( $flags = 0 ) {
global $wgFeedClasses;
$feedFormatNames = array_keys( $wgFeedClasses );
$feedFormatNames = array_keys( $this->getConfig()->get( 'FeedClasses' ) );
$ret = array(
'feedformat' => array(
ApiBase::PARAM_DFLT => 'rss',

View file

@ -154,9 +154,9 @@ abstract class ApiFormatBase extends ApiBase {
$this->getMain()->getRequest()->response()->header( "Content-Type: $mime; charset=utf-8" );
//Set X-Frame-Options API results (bug 39180)
global $wgApiFrameOptions;
if ( $wgApiFrameOptions ) {
$this->getMain()->getRequest()->response()->header( "X-Frame-Options: $wgApiFrameOptions" );
$apiFrameOptions = $this->getConfig()->get( 'ApiFrameOptions' );
if ( $apiFrameOptions ) {
$this->getMain()->getRequest()->response()->header( "X-Frame-Options: $apiFrameOptions" );
}
if ( $isHtml ) {

View file

@ -98,8 +98,6 @@ class ApiImport extends ApiBase {
}
public function getAllowedParams() {
global $wgImportSources;
return array(
'token' => array(
ApiBase::PARAM_TYPE => 'string',
@ -110,7 +108,7 @@ class ApiImport extends ApiBase {
ApiBase::PARAM_TYPE => 'upload',
),
'interwikisource' => array(
ApiBase::PARAM_TYPE => $wgImportSources
ApiBase::PARAM_TYPE => $this->getConfig()->get( 'ImportSources' ),
),
'interwikipage' => null,
'fullhistory' => false,

View file

@ -79,8 +79,6 @@ class ApiLogin extends ApiBase {
$loginForm = new LoginForm();
$loginForm->setContext( $context );
global $wgCookiePrefix, $wgPasswordAttemptThrottle;
$authRes = $loginForm->authenticateUserData();
switch ( $authRes ) {
case LoginForm::SUCCESS:
@ -100,14 +98,14 @@ class ApiLogin extends ApiBase {
$result['lguserid'] = intval( $user->getId() );
$result['lgusername'] = $user->getName();
$result['lgtoken'] = $user->getToken();
$result['cookieprefix'] = $wgCookiePrefix;
$result['cookieprefix'] = $this->getConfig()->get( 'CookiePrefix' );
$result['sessionid'] = session_id();
break;
case LoginForm::NEED_TOKEN:
$result['result'] = 'NeedToken';
$result['token'] = $loginForm->getLoginToken();
$result['cookieprefix'] = $wgCookiePrefix;
$result['cookieprefix'] = $this->getConfig()->get( 'CookiePrefix' );
$result['sessionid'] = session_id();
break;
@ -149,7 +147,8 @@ class ApiLogin extends ApiBase {
case LoginForm::THROTTLED:
$result['result'] = 'Throttled';
$result['wait'] = intval( $wgPasswordAttemptThrottle['seconds'] );
$throttle = $this->getConfig()->get( 'PasswordAttemptThrottle' );
$result['wait'] = intval( $throttle['seconds'] );
break;
case LoginForm::USER_BLOCKED:

View file

@ -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' );
}
@ -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;

View file

@ -45,7 +45,6 @@ class ApiOpenSearch extends ApiBase {
}
public function execute() {
global $wgEnableOpenSearchSuggest, $wgSearchSuggestCacheExpiry;
$params = $this->extractRequestParams();
$search = $params['search'];
$limit = $params['limit'];
@ -53,11 +52,11 @@ class ApiOpenSearch extends ApiBase {
$suggest = $params['suggest'];
// Some script that was loaded regardless of wgEnableOpenSearchSuggest, likely cached.
if ( $suggest && !$wgEnableOpenSearchSuggest ) {
if ( $suggest && !$this->getConfig()->get( 'EnableOpenSearchSuggest' ) ) {
$searches = array();
} else {
// Open search results may be stored for a very long time
$this->getMain()->setCacheMaxAge( $wgSearchSuggestCacheExpiry );
$this->getMain()->setCacheMaxAge( $this->getConfig()->get( 'SearchSuggestCacheExpiry' ) );
$this->getMain()->setCacheMode( 'public' );
$searcher = new StringPrefixSearch;
@ -70,12 +69,10 @@ class ApiOpenSearch extends ApiBase {
}
public function getAllowedParams() {
global $wgOpenSearchDefaultLimit;
return array(
'search' => null,
'limit' => array(
ApiBase::PARAM_DFLT => $wgOpenSearchDefaultLimit,
ApiBase::PARAM_DFLT => $this->getConfig()->get( 'OpenSearchDefaultLimit' ),
ApiBase::PARAM_TYPE => 'limit',
ApiBase::PARAM_MIN => 1,
ApiBase::PARAM_MAX => 100,

View file

@ -574,9 +574,9 @@ class ApiParse extends ApiBase {
'and will be removed in MediaWiki 1.24. Use "prop=langlinks" ' .
'to generate your own HTML.' );
global $wgContLang, $wgHideInterlanguageLinks;
global $wgContLang;
if ( $wgHideInterlanguageLinks || count( $languages ) == 0 ) {
if ( $this->getConfig()->get( 'HideInterlanguageLinks' ) || count( $languages ) == 0 ) {
return '';
}

View file

@ -29,7 +29,6 @@
*/
class ApiProtect extends ApiBase {
public function execute() {
global $wgRestrictionLevels;
$params = $this->extractRequestParams();
$pageObj = $this->getTitleOrPageId( $params, 'fromdbmaster' );
@ -74,7 +73,7 @@ class ApiProtect extends ApiBase {
if ( !in_array( $p[0], $restrictionTypes ) && $p[0] != 'create' ) {
$this->dieUsageMsg( array( 'protect-invalidaction', $p[0] ) );
}
if ( !in_array( $p[1], $wgRestrictionLevels ) && $p[1] != 'all' ) {
if ( !in_array( $p[1], $this->getConfig()->get( 'RestrictionLevels' ) ) && $p[1] != 'all' ) {
$this->dieUsageMsg( array( 'protect-invalidlevel', $p[1] ) );
}

View file

@ -54,17 +54,16 @@ class ApiPurge extends ApiBase {
if ( $forceLinkUpdate || $forceRecursiveLinkUpdate ) {
if ( !$this->getUser()->pingLimiter( 'linkpurge' ) ) {
global $wgEnableParserCache;
$popts = $page->makeParserOptions( 'canonical' );
# Parse content; note that HTML generation is only needed if we want to cache the result.
$content = $page->getContent( Revision::RAW );
$enableParserCache = $this->getConfig()->get( 'EnableParserCache' );
$p_result = $content->getParserOutput(
$title,
$page->getLatest(),
$popts,
$wgEnableParserCache
$enableParserCache
);
# Update the links tables
@ -74,7 +73,7 @@ class ApiPurge extends ApiBase {
$r['linkupdate'] = '';
if ( $wgEnableParserCache ) {
if ( $enableParserCache ) {
$pcache = ParserCache::singleton();
$pcache->save( $p_result, $page, $popts );
}

View file

@ -131,13 +131,13 @@ class ApiQuery extends ApiBase {
$this->mModuleMgr = new ApiModuleManager( $this );
// Allow custom modules to be added in LocalSettings.php
global $wgAPIPropModules, $wgAPIListModules, $wgAPIMetaModules;
$config = $this->getConfig();
$this->mModuleMgr->addModules( self::$QueryPropModules, 'prop' );
$this->mModuleMgr->addModules( $wgAPIPropModules, 'prop' );
$this->mModuleMgr->addModules( $config->get( 'APIPropModules' ), 'prop' );
$this->mModuleMgr->addModules( self::$QueryListModules, 'list' );
$this->mModuleMgr->addModules( $wgAPIListModules, 'list' );
$this->mModuleMgr->addModules( $config->get( 'APIListModules' ), 'list' );
$this->mModuleMgr->addModules( self::$QueryMetaModules, 'meta' );
$this->mModuleMgr->addModules( $wgAPIMetaModules, 'meta' );
$this->mModuleMgr->addModules( $config->get( 'APIMetaModules' ), 'meta' );
// Create PageSet that will process titles/pageids/revids/generator
$this->mPageSet = new ApiPageSet( $this );

View file

@ -228,8 +228,7 @@ class ApiQueryAllImages extends ApiQueryGeneratorBase {
}
if ( !is_null( $params['mime'] ) ) {
global $wgMiserMode;
if ( $wgMiserMode ) {
if ( $this->getConfig()->get( 'MiserMode' ) ) {
$this->dieUsage( 'MIME search disabled in Miser Mode', 'mimesearchdisabled' );
}

View file

@ -63,14 +63,13 @@ class ApiQueryAllMessages extends ApiQueryBase {
if ( in_array( '*', $params['messages'] ) ) {
$message_names = Language::getMessageKeysFor( $langObj->getCode() );
if ( $params['includelocal'] ) {
global $wgLanguageCode;
$message_names = array_unique( array_merge(
$message_names,
// Pass in the content language code so we get local messages that have a
// MediaWiki:msgkey page. We might theoretically miss messages that have no
// MediaWiki:msgkey page but do have a MediaWiki:msgkey/lang page, but that's
// just a stupid case.
MessageCache::singleton()->getAllMessageKeys( $wgLanguageCode )
MessageCache::singleton()->getAllMessageKeys( $this->getConfig()->get( 'LanguageCode' ) )
) );
}
sort( $message_names );

View file

@ -225,8 +225,6 @@ class ApiQueryAllPages extends ApiQueryGeneratorBase {
}
public function getAllowedParams() {
global $wgRestrictionLevels;
return array(
'from' => null,
'continue' => null,
@ -255,7 +253,7 @@ class ApiQueryAllPages extends ApiQueryGeneratorBase {
ApiBase::PARAM_ISMULTI => true
),
'prlevel' => array(
ApiBase::PARAM_TYPE => $wgRestrictionLevels,
ApiBase::PARAM_TYPE => $this->getConfig()->get( 'RestrictionLevels' ),
ApiBase::PARAM_ISMULTI => true
),
'prfiltercascade' => array(

View file

@ -155,7 +155,6 @@ class ApiQueryAllUsers extends ApiQueryBase {
}
if ( $params['activeusers'] ) {
global $wgActiveUserDays;
$this->addTables( 'recentchanges' );
$this->addJoinConds( array( 'recentchanges' => array(
@ -165,7 +164,7 @@ class ApiQueryAllUsers extends ApiQueryBase {
$this->addFields( array( 'recentedits' => 'COUNT(*)' ) );
$this->addWhere( 'rc_log_type IS NULL OR rc_log_type != ' . $db->addQuotes( 'newusers' ) );
$timestamp = $db->timestamp( wfTimestamp( TS_UNIX ) - $wgActiveUserDays * 24 * 3600 );
$timestamp = $db->timestamp( wfTimestamp( TS_UNIX ) - $this->getConfig()->get( 'ActiveUserDays' ) * 24 * 3600 );
$this->addWhere( 'rc_timestamp >= ' . $db->addQuotes( $timestamp ) );
$this->addOption( 'GROUP BY', $userFieldToSort );
@ -368,8 +367,6 @@ class ApiQueryAllUsers extends ApiQueryBase {
}
public function getParamDescription() {
global $wgActiveUserDays;
return array(
'from' => 'The user name to start enumerating from',
'to' => 'The user name to stop enumerating at',
@ -391,7 +388,7 @@ class ApiQueryAllUsers extends ApiQueryBase {
),
'limit' => 'How many total user names to return',
'witheditsonly' => 'Only list users who have made edits',
'activeusers' => "Only list users active in the last {$wgActiveUserDays} days(s)"
'activeusers' => "Only list users active in the last {$this->getConfig()->get( 'ActiveUserDays' )} days(s)"
);
}

View file

@ -321,8 +321,7 @@ abstract class ApiQueryBase extends ApiBase {
);
$this->profileDBOut();
global $wgAPIMaxDBRows;
if ( $rowcount > $wgAPIMaxDBRows ) {
if ( $rowcount > $this->getConfig()->get( 'APIMaxDBRows' ) ) {
return false;
}

View file

@ -109,14 +109,14 @@ class ApiQueryBlocks extends ApiQueryBase {
$this->addWhereFld( 'ipb_auto', 0 );
}
if ( isset( $params['ip'] ) ) {
global $wgBlockCIDRLimit;
$blockCIDRLimit = $this->getConfig()->get( 'BlockCIDRLimit' );
if ( IP::isIPv4( $params['ip'] ) ) {
$type = 'IPv4';
$cidrLimit = $wgBlockCIDRLimit['IPv4'];
$cidrLimit = $blockCIDRLimit['IPv4'];
$prefixLen = 0;
} elseif ( IP::isIPv6( $params['ip'] ) ) {
$type = 'IPv6';
$cidrLimit = $wgBlockCIDRLimit['IPv6'];
$cidrLimit = $blockCIDRLimit['IPv6'];
$prefixLen = 3; // IP::toHex output is prefixed with "v6-"
} else {
$this->dieUsage( 'IP parameter is not valid', 'param_ip' );
@ -331,7 +331,7 @@ class ApiQueryBlocks extends ApiQueryBase {
}
public function getParamDescription() {
global $wgBlockCIDRLimit;
$blockCIDRLimit = $this->getConfig()->get( 'BlockCIDRLimit' );
$p = $this->getModulePrefix();
return array(
@ -343,7 +343,7 @@ class ApiQueryBlocks extends ApiQueryBase {
'ip' => array(
'Get all blocks applying to this IP or CIDR range, including range blocks.',
"Cannot be used together with bkusers. CIDR ranges broader than " .
"IPv4/{$wgBlockCIDRLimit['IPv4']} or IPv6/{$wgBlockCIDRLimit['IPv6']} " .
"IPv4/{$blockCIDRLimit['IPv4']} or IPv6/{$blockCIDRLimit['IPv6']} " .
"are not accepted"
),
'limit' => 'The maximum amount of blocks to list',
@ -427,18 +427,18 @@ class ApiQueryBlocks extends ApiQueryBase {
}
public function getPossibleErrors() {
global $wgBlockCIDRLimit;
$blockCIDRLimit = $this->getConfig()->get( 'BlockCIDRLimit' );
return array_merge( parent::getPossibleErrors(),
$this->getRequireMaxOneParameterErrorMessages( array( 'users', 'ip' ) ),
array(
array(
'code' => 'cidrtoobroad',
'info' => "IPv4 CIDR ranges broader than /{$wgBlockCIDRLimit['IPv4']} are not accepted"
'info' => "IPv4 CIDR ranges broader than /{$blockCIDRLimit['IPv4']} are not accepted"
),
array(
'code' => 'cidrtoobroad',
'info' => "IPv6 CIDR ranges broader than /{$wgBlockCIDRLimit['IPv6']} are not accepted"
'info' => "IPv6 CIDR ranges broader than /{$blockCIDRLimit['IPv6']} are not accepted"
),
array( 'code' => 'param_ip', 'info' => 'IP parameter is not valid' ),
array( 'code' => 'param_user', 'info' => 'User parameter may not be empty' ),

View file

@ -86,9 +86,8 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase {
// Scanning large datasets for rare categories sucks, and I already told
// how to have efficient subcategory access :-) ~~~~ (oh well, domas)
global $wgMiserMode;
$miser_ns = array();
if ( $wgMiserMode ) {
if ( $this->getConfig()->get( 'MiserMode' ) ) {
$miser_ns = $params['namespace'];
} else {
$this->addWhereFld( 'page_namespace', $params['namespace'] );
@ -339,7 +338,6 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase {
}
public function getParamDescription() {
global $wgMiserMode;
$p = $this->getModulePrefix();
$desc = array(
'title' => "Which category to enumerate (required). Must include " .
@ -374,7 +372,7 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase {
'limit' => 'The maximum number of pages to return.',
);
if ( $wgMiserMode ) {
if ( $this->getConfig()->get( 'MiserMode' ) ) {
$desc['namespace'] = array(
$desc['namespace'],
"NOTE: Due to \$wgMiserMode, using this may result in fewer than \"{$p}limit\" results",

View file

@ -59,9 +59,8 @@ class ApiQueryExtLinksUsage extends ApiQueryGeneratorBase {
$this->addOption( 'USE INDEX', 'el_index' );
$this->addWhere( 'page_id=el_from' );
global $wgMiserMode;
$miser_ns = array();
if ( $wgMiserMode ) {
if ( $this->getConfig()->get( 'MiserMode' ) ) {
$miser_ns = $params['namespace'];
} else {
$this->addWhereFld( 'page_namespace', $params['namespace'] );
@ -209,7 +208,6 @@ class ApiQueryExtLinksUsage extends ApiQueryGeneratorBase {
}
public function getParamDescription() {
global $wgMiserMode;
$p = $this->getModulePrefix();
$desc = array(
'prop' => array(
@ -230,7 +228,7 @@ class ApiQueryExtLinksUsage extends ApiQueryGeneratorBase {
'expandurl' => 'Expand protocol-relative URLs with the canonical protocol',
);
if ( $wgMiserMode ) {
if ( $this->getConfig()->get( 'MiserMode' ) ) {
$desc['namespace'] = array(
$desc['namespace'],
"NOTE: Due to \$wgMiserMode, using this may result in fewer than \"{$p}limit\" results",

View file

@ -256,15 +256,13 @@ class ApiQueryImageInfo extends ApiQueryBase {
* @return array Array of parameters for transform.
*/
protected function mergeThumbParams( $image, $thumbParams, $otherParams ) {
global $wgThumbLimits;
if ( !isset( $thumbParams['width'] ) && isset( $thumbParams['height'] ) ) {
// We want to limit only by height in this situation, so pass the
// image's full width as the limiting width. But some file types
// don't have a width of their own, so pick something arbitrary so
// thumbnailing the default icon works.
if ( $image->getWidth() <= 0 ) {
$thumbParams['width'] = max( $wgThumbLimits );
$thumbParams['width'] = max( $this->getConfig()->get( 'ThumbLimits' ) );
} else {
$thumbParams['width'] = $image->getWidth();
}

View file

@ -57,21 +57,20 @@ class ApiQueryInfo extends ApiQueryBase {
* @return void
*/
public function requestExtraData( $pageSet ) {
global $wgDisableCounters, $wgContentHandlerUseDB;
$pageSet->requestField( 'page_restrictions' );
// when resolving redirects, no page will have this field
if ( !$pageSet->isResolvingRedirects() ) {
$pageSet->requestField( 'page_is_redirect' );
}
$pageSet->requestField( 'page_is_new' );
if ( !$wgDisableCounters ) {
$config = $this->getConfig();
if ( !$config->get( 'DisableCounters' ) ) {
$pageSet->requestField( 'page_counter' );
}
$pageSet->requestField( 'page_touched' );
$pageSet->requestField( 'page_latest' );
$pageSet->requestField( 'page_len' );
if ( $wgContentHandlerUseDB ) {
if ( $config->get( 'ContentHandlerUseDB' ) ) {
$pageSet->requestField( 'page_content_model' );
}
}
@ -295,9 +294,7 @@ class ApiQueryInfo extends ApiQueryBase {
: array();
$this->pageIsNew = $pageSet->getCustomField( 'page_is_new' );
global $wgDisableCounters;
if ( !$wgDisableCounters ) {
if ( !$this->getConfig()->get( 'DisableCounters' ) ) {
$this->pageCounter = $pageSet->getCustomField( 'page_counter' );
}
$this->pageTouched = $pageSet->getCustomField( 'page_touched' );
@ -359,11 +356,9 @@ class ApiQueryInfo extends ApiQueryBase {
$pageInfo['pagelanguage'] = $title->getPageLanguage()->getCode();
if ( $titleExists ) {
global $wgDisableCounters;
$pageInfo['touched'] = wfTimestamp( TS_ISO_8601, $this->pageTouched[$pageid] );
$pageInfo['lastrevid'] = intval( $this->pageLatest[$pageid] );
$pageInfo['counter'] = $wgDisableCounters
$pageInfo['counter'] = $this->getConfig()->get( 'DisableCounters' )
? ''
: intval( $this->pageCounter[$pageid] );
$pageInfo['length'] = intval( $this->pageLength[$pageid] );
@ -711,15 +706,14 @@ class ApiQueryInfo extends ApiQueryBase {
* Get the count of watchers and put it in $this->watchers
*/
private function getWatcherInfo() {
global $wgUnwatchedPageThreshold;
if ( count( $this->everything ) == 0 ) {
return;
}
$user = $this->getUser();
$canUnwatchedpages = $user->isAllowed( 'unwatchedpages' );
if ( !$canUnwatchedpages && !is_int( $wgUnwatchedPageThreshold ) ) {
$unwatchedPageThreshold = $this->getConfig()->get( 'UnwatchedPageThreshold' );
if ( !$canUnwatchedpages && !is_int( $unwatchedPageThreshold ) ) {
return;
}
@ -737,7 +731,7 @@ class ApiQueryInfo extends ApiQueryBase {
) );
$this->addOption( 'GROUP BY', array( 'wl_namespace', 'wl_title' ) );
if ( !$canUnwatchedpages ) {
$this->addOption( 'HAVING', "COUNT(*) >= $wgUnwatchedPageThreshold" );
$this->addOption( 'HAVING', "COUNT(*) >= $unwatchedPageThreshold" );
}
$res = $this->select( __METHOD__ );

View file

@ -187,8 +187,7 @@ class ApiQueryLogEvents extends ApiQueryBase {
$prefix = $params['prefix'];
if ( !is_null( $prefix ) ) {
global $wgMiserMode;
if ( $wgMiserMode ) {
if ( $this->getConfig()->get( 'MiserMode' ) ) {
$this->dieUsage( 'Prefix search disabled in Miser Mode', 'prefixsearchdisabled' );
}
@ -449,10 +448,12 @@ class ApiQueryLogEvents extends ApiQueryBase {
return $vals;
}
/**
* @return array
*/
private function getAllowedLogActions() {
global $wgLogActions, $wgLogActionsHandlers;
return array_keys( array_merge( $wgLogActions, $wgLogActionsHandlers ) );
$config = $this->getConfig();
return array_keys( array_merge( $config->get( 'LogActions' ), $config->get( 'LogActionsHandlers' ) ) );
}
public function getCacheMode( $params ) {
@ -472,8 +473,7 @@ class ApiQueryLogEvents extends ApiQueryBase {
}
public function getAllowedParams( $flags = 0 ) {
global $wgLogTypes;
$config = $this->getConfig();
return array(
'prop' => array(
ApiBase::PARAM_ISMULTI => true,
@ -492,7 +492,7 @@ class ApiQueryLogEvents extends ApiQueryBase {
)
),
'type' => array(
ApiBase::PARAM_TYPE => $wgLogTypes
ApiBase::PARAM_TYPE => $config->get( 'LogTypes' )
),
'action' => array(
// validation on request is done in execute()
@ -567,8 +567,6 @@ class ApiQueryLogEvents extends ApiQueryBase {
}
public function getResultProperties() {
global $wgLogTypes;
return array(
'ids' => array(
'logid' => 'integer',
@ -580,7 +578,7 @@ class ApiQueryLogEvents extends ApiQueryBase {
),
'type' => array(
'type' => array(
ApiBase::PROP_TYPE => $wgLogTypes
ApiBase::PROP_TYPE => $this->getConfig()->get( 'LogTypes' )
),
'action' => 'string'
),

View file

@ -175,8 +175,6 @@ class ApiQueryProtectedTitles extends ApiQueryGeneratorBase {
}
public function getAllowedParams() {
global $wgRestrictionLevels;
return array(
'namespace' => array(
ApiBase::PARAM_ISMULTI => true,
@ -184,7 +182,7 @@ class ApiQueryProtectedTitles extends ApiQueryGeneratorBase {
),
'level' => array(
ApiBase::PARAM_ISMULTI => true,
ApiBase::PARAM_TYPE => array_diff( $wgRestrictionLevels, array( '' ) )
ApiBase::PARAM_TYPE => array_diff( $this->getConfig()->get( 'RestrictionLevels' ), array( '' ) )
),
'limit' => array(
ApiBase::PARAM_DFLT => 10,
@ -246,8 +244,6 @@ class ApiQueryProtectedTitles extends ApiQueryGeneratorBase {
}
public function getResultProperties() {
global $wgRestrictionLevels;
return array(
'' => array(
'ns' => 'namespace',
@ -277,7 +273,7 @@ class ApiQueryProtectedTitles extends ApiQueryGeneratorBase {
),
'level' => array(
'level' => array(
ApiBase::PROP_TYPE => array_diff( $wgRestrictionLevels, array( '' ) )
ApiBase::PROP_TYPE => array_diff( $this->getConfig()->get( 'RestrictionLevels' ), array( '' ) )
)
)
);

View file

@ -35,10 +35,10 @@ class ApiQueryQueryPage extends ApiQueryGeneratorBase {
public function __construct( ApiQuery $query, $moduleName ) {
parent::__construct( $query, $moduleName, 'qp' );
// Build mapping from special page names to QueryPage classes
global $wgAPIUselessQueryPages;
$uselessQueryPages = $this->getConfig()->get( 'APIUselessQueryPages' );
$this->qpMap = array();
foreach ( QueryPage::getPages() as $page ) {
if ( !in_array( $page[1], $wgAPIUselessQueryPages ) ) {
if ( !in_array( $page[1], $uselessQueryPages ) ) {
$this->qpMap[$page[1]] = $page[0];
}
}
@ -56,8 +56,6 @@ class ApiQueryQueryPage extends ApiQueryGeneratorBase {
* @param ApiPageSet $resultPageSet
*/
public function run( $resultPageSet = null ) {
global $wgQueryCacheLimit;
$params = $this->extractRequestParams();
$result = $this->getResult();
@ -77,7 +75,7 @@ class ApiQueryQueryPage extends ApiQueryGeneratorBase {
if ( $ts ) {
$r['cachedtimestamp'] = wfTimestamp( TS_ISO_8601, $ts );
}
$r['maxresults'] = $wgQueryCacheLimit;
$r['maxresults'] = $this->getConfig()->get( 'QueryCacheLimit' );
}
}
$result->addValue( array( 'query' ), $this->getModuleName(), $r );

View file

@ -738,7 +738,6 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase {
}
public function getResultProperties() {
global $wgLogTypes;
$props = array(
'' => array(
'type' => array(
@ -814,7 +813,7 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase {
ApiBase::PROP_NULLABLE => true
),
'logtype' => array(
ApiBase::PROP_TYPE => $wgLogTypes,
ApiBase::PROP_TYPE => $config->get( 'LogTypes' ),
ApiBase::PROP_NULLABLE => true
),
'logaction' => array(

View file

@ -624,10 +624,9 @@ class ApiQueryRevisions extends ApiQueryBase {
}
if ( $content && ( !is_null( $this->diffto ) || !is_null( $this->difftotext ) ) ) {
global $wgAPIMaxUncachedDiffs;
static $n = 0; // Number of uncached diffs we've had
if ( $n < $wgAPIMaxUncachedDiffs ) {
if ( $n < $config->get( 'APIMaxUncachedDiffs' ) ) {
$vals['diff'] = array();
$context = new DerivativeContext( $this->getContext() );
$context->setTitle( $title );

View file

@ -257,8 +257,6 @@ class ApiQuerySearch extends ApiQueryGeneratorBase {
}
public function getAllowedParams() {
global $wgSearchType;
$params = array(
'search' => array(
ApiBase::PARAM_TYPE => 'string',
@ -319,7 +317,7 @@ class ApiQuerySearch extends ApiQueryGeneratorBase {
$alternatives[0] = self::BACKEND_NULL_PARAM;
}
$params['backend'] = array(
ApiBase::PARAM_DFLT => $wgSearchType,
ApiBase::PARAM_DFLT => $this->getConfig()->get( 'SearchType' ),
ApiBase::PARAM_TYPE => $alternatives,
);
}

View file

@ -120,31 +120,34 @@ class ApiQuerySiteinfo extends ApiQueryBase {
}
protected function appendGeneralInfo( $property ) {
global $wgContLang, $wgDisableLangConversion, $wgDisableTitleConversion;
global $wgContLang;
$config = $this->getConfig();
$data = array();
$mainPage = Title::newMainPage();
$data['mainpage'] = $mainPage->getPrefixedText();
$data['base'] = wfExpandUrl( $mainPage->getFullURL(), PROTO_CURRENT );
$data['sitename'] = $GLOBALS['wgSitename'];
$data['sitename'] = $config->get( 'Sitename' );
// wgLogo can either be a relative or an absolute path
// make sure we always return an absolute path
$data['logo'] = wfExpandUrl( $GLOBALS['wgLogo'], PROTO_RELATIVE );
$data['logo'] = wfExpandUrl( $config->get( 'Logo' ), PROTO_RELATIVE );
$data['generator'] = "MediaWiki {$config->get( 'Version' )}";
$data['generator'] = "MediaWiki {$GLOBALS['wgVersion']}";
$data['phpversion'] = phpversion();
$data['phpsapi'] = PHP_SAPI;
$data['dbtype'] = $GLOBALS['wgDBtype'];
$data['dbtype'] = $config->get( 'DBtype' );
$data['dbversion'] = $this->getDB()->getServerVersion();
$allowFrom = array( '' );
$allowException = true;
if ( !$GLOBALS['wgAllowExternalImages'] ) {
if ( $GLOBALS['wgEnableImageWhitelist'] ) {
if ( !$config->get( 'AllowExternalImages' ) ) {
if ( $config->get( 'EnableImageWhitelist' ) ) {
$data['imagewhitelistenabled'] = '';
}
$allowFrom = $GLOBALS['wgAllowExternalImagesFrom'];
$allowFrom = $config->get( 'AllowExternalImagesFrom' );
$allowException = !empty( $allowFrom );
}
if ( $allowException ) {
@ -152,11 +155,11 @@ class ApiQuerySiteinfo extends ApiQueryBase {
$this->getResult()->setIndexedTagName( $data['externalimages'], 'prefix' );
}
if ( !$wgDisableLangConversion ) {
if ( !$config->get( 'DisableLangConversion' ) ) {
$data['langconversion'] = '';
}
if ( !$wgDisableTitleConversion ) {
if ( !$config->get( 'DisableTitleConversion' ) ) {
$data['titleconversion'] = '';
}
@ -177,22 +180,22 @@ class ApiQuerySiteinfo extends ApiQueryBase {
$data['linktrail'] = '';
}
$git = SpecialVersion::getGitHeadSha1( $GLOBALS['IP'] );
global $IP;
$git = SpecialVersion::getGitHeadSha1( $IP );
if ( $git ) {
$data['git-hash'] = $git;
$data['git-branch'] =
SpecialVersion::getGitCurrentBranch( $GLOBALS['IP'] );
} else {
$svn = SpecialVersion::getSvnRevision( $GLOBALS['IP'] );
$svn = SpecialVersion::getSvnRevision( $IP );
if ( $svn ) {
$data['rev'] = $svn;
}
}
// 'case-insensitive' option is reserved for future
$data['case'] = $GLOBALS['wgCapitalLinks'] ? 'first-letter' : 'case-sensitive';
$data['lang'] = $GLOBALS['wgLanguageCode'];
$data['case'] = $config->get( 'CapitalLinks' ) ? 'first-letter' : 'case-sensitive';
$data['lang'] = $config->get( 'LanguageCode' );
$fallbacks = array();
foreach ( $wgContLang->getFallbackLanguages() as $code ) {
@ -222,12 +225,12 @@ class ApiQuerySiteinfo extends ApiQueryBase {
$data['readonly'] = '';
$data['readonlyreason'] = wfReadOnlyReason();
}
if ( $GLOBALS['wgEnableWriteAPI'] ) {
if ( $config->get( 'EnableWriteAPI' ) ) {
$data['writeapi'] = '';
}
$tz = $GLOBALS['wgLocaltimezone'];
$offset = $GLOBALS['wgLocalTZoffset'];
$tz = $config->get( 'Localtimezone' );
$offset = $config->get( 'LocalTZoffset' );
if ( is_null( $tz ) ) {
$tz = 'UTC';
$offset = 0;
@ -236,33 +239,34 @@ class ApiQuerySiteinfo extends ApiQueryBase {
}
$data['timezone'] = $tz;
$data['timeoffset'] = intval( $offset );
$data['articlepath'] = $GLOBALS['wgArticlePath'];
$data['scriptpath'] = $GLOBALS['wgScriptPath'];
$data['script'] = $GLOBALS['wgScript'];
$data['variantarticlepath'] = $GLOBALS['wgVariantArticlePath'];
$data['server'] = $GLOBALS['wgServer'];
$data['servername'] = $GLOBALS['wgServerName'];
$data['articlepath'] = $config->get( 'ArticlePath' );
$data['scriptpath'] = $config->get( 'ScriptPath' );
$data['script'] = $config->get( 'Script' );
$data['variantarticlepath'] = $config->get( 'VariantArticlePath' );
$data['server'] = $config->get( 'Server' );
$data['servername'] = $config->get( 'ServerName' );
$data['wikiid'] = wfWikiID();
$data['time'] = wfTimestamp( TS_ISO_8601, time() );
if ( $GLOBALS['wgMiserMode'] ) {
if ( $config->get( 'MiserMode' ) ) {
$data['misermode'] = '';
}
$data['maxuploadsize'] = UploadBase::getMaxUploadSize();
$data['thumblimits'] = $GLOBALS['wgThumbLimits'];
$data['thumblimits'] = $config->get( 'ThumbLimits' );
$this->getResult()->setIndexedTagName( $data['thumblimits'], 'limit' );
$data['imagelimits'] = array();
$this->getResult()->setIndexedTagName( $data['imagelimits'], 'limit' );
foreach ( $GLOBALS['wgImageLimits'] as $k => $limit ) {
foreach ( $config->get( 'ImageLimits' ) as $k => $limit ) {
$data['imagelimits'][$k] = array( 'width' => $limit[0], 'height' => $limit[1] );
}
if ( !empty( $GLOBALS['wgFavicon'] ) ) {
$favicon = $config->get( 'Favicon' );
if ( !empty( $favicon ) ) {
// wgFavicon can either be a relative or an absolute path
// make sure we always return an absolute path
$data['favicon'] = wfExpandUrl( $GLOBALS['wgFavicon'], PROTO_RELATIVE );
$data['favicon'] = wfExpandUrl( $favicon, PROTO_RELATIVE );
}
wfRunHooks( 'APIQuerySiteInfoGeneralInfo', array( $this, &$data ) );
@ -309,8 +313,8 @@ class ApiQuerySiteinfo extends ApiQueryBase {
}
protected function appendNamespaceAliases( $property ) {
global $wgNamespaceAliases, $wgContLang;
$aliases = array_merge( $wgNamespaceAliases, $wgContLang->getNamespaceAliases() );
global $wgContLang;
$aliases = array_merge( $this->getConfig()->get( 'NamespaceAliases' ), $wgContLang->getNamespaceAliases() );
$namespaces = $wgContLang->getNamespaces();
$data = array();
foreach ( $aliases as $title => $ns ) {
@ -415,11 +419,11 @@ class ApiQuerySiteinfo extends ApiQueryBase {
}
protected function appendDbReplLagInfo( $property, $includeAll ) {
global $wgShowHostnames;
$data = array();
$lb = wfGetLB();
$showHostnames = $this->getConfig()->get( 'ShowHostnames' );
if ( $includeAll ) {
if ( !$wgShowHostnames ) {
if ( !$showHostnames ) {
$this->dieUsage(
'Cannot view all servers info unless $wgShowHostnames is true',
'includeAllDenied'
@ -436,7 +440,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
} else {
list( , $lag, $index ) = $lb->getMaxLag();
$data[] = array(
'host' => $wgShowHostnames
'host' => $showHostnames
? $lb->getServerName( $index )
: '',
'lag' => intval( $lag )
@ -450,11 +454,10 @@ class ApiQuerySiteinfo extends ApiQueryBase {
}
protected function appendStatistics( $property ) {
global $wgDisableCounters;
$data = array();
$data['pages'] = intval( SiteStats::pages() );
$data['articles'] = intval( SiteStats::articles() );
if ( !$wgDisableCounters ) {
if ( !$this->getConfig()->get( 'DisableCounters' ) ) {
$data['views'] = intval( SiteStats::views() );
}
$data['edits'] = intval( SiteStats::edits() );
@ -470,33 +473,32 @@ class ApiQuerySiteinfo extends ApiQueryBase {
}
protected function appendUserGroups( $property, $numberInGroup ) {
global $wgGroupPermissions, $wgAddGroups, $wgRemoveGroups;
global $wgGroupsAddToSelf, $wgGroupsRemoveFromSelf;
$config = $this->getConfig();
$data = array();
$result = $this->getResult();
foreach ( $wgGroupPermissions as $group => $permissions ) {
foreach ( $config->get( 'GroupPermissions' ) as $group => $permissions ) {
$arr = array(
'name' => $group,
'rights' => array_keys( $permissions, true ),
);
if ( $numberInGroup ) {
global $wgAutopromote;
$autopromote = $config->get( 'Autopromote' );
if ( $group == 'user' ) {
$arr['number'] = SiteStats::users();
// '*' and autopromote groups have no size
} elseif ( $group !== '*' && !isset( $wgAutopromote[$group] ) ) {
} elseif ( $group !== '*' && !isset( $autopromote[$group] ) ) {
$arr['number'] = SiteStats::numberInGroup( $group );
}
}
$groupArr = array(
'add' => $wgAddGroups,
'remove' => $wgRemoveGroups,
'add-self' => $wgGroupsAddToSelf,
'remove-self' => $wgGroupsRemoveFromSelf
'add' => $config->get( 'AddGroups' ),
'remove' => $config->get( 'RemoveGroups' ),
'add-self' => $config->get( 'GroupsAddToSelf' ),
'remove-self' => $config->get( 'GroupsRemoveFromSelf' )
);
foreach ( $groupArr as $type => $rights ) {
@ -516,10 +518,8 @@ class ApiQuerySiteinfo extends ApiQueryBase {
}
protected function appendFileExtensions( $property ) {
global $wgFileExtensions;
$data = array();
foreach ( array_unique( $wgFileExtensions ) as $ext ) {
foreach ( array_unique( $this->getConfig()->get( 'FileExtensions' ) ) as $ext ) {
$data[] = array( 'ext' => $ext );
}
$this->getResult()->setIndexedTagName( $data, 'fe' );
@ -528,9 +528,8 @@ class ApiQuerySiteinfo extends ApiQueryBase {
}
protected function appendExtensions( $property ) {
global $wgExtensionCredits;
$data = array();
foreach ( $wgExtensionCredits as $type => $extensions ) {
foreach ( $this->getConfig()->get( 'ExtensionCredits' ) as $type => $extensions ) {
foreach ( $extensions as $ext ) {
$ret = array();
$ret['type'] = $type;
@ -611,10 +610,10 @@ class ApiQuerySiteinfo extends ApiQueryBase {
}
protected function appendRightsInfo( $property ) {
global $wgRightsPage, $wgRightsUrl, $wgRightsText;
$title = Title::newFromText( $wgRightsPage );
$url = $title ? wfExpandUrl( $title->getFullURL(), PROTO_CURRENT ) : $wgRightsUrl;
$text = $wgRightsText;
$config = $this->getConfig();
$title = Title::newFromText( $config->get( 'RightsPage' ) );
$url = $title ? wfExpandUrl( $title->getFullURL(), PROTO_CURRENT ) : $config->get( 'RightsUrl' );
$text = $config->get( 'RightsText' );
if ( !$text && $title ) {
$text = $title->getPrefixedText();
}
@ -628,14 +627,12 @@ class ApiQuerySiteinfo extends ApiQueryBase {
}
protected function appendRestrictions( $property ) {
global $wgRestrictionTypes, $wgRestrictionLevels,
$wgCascadingRestrictionLevels, $wgSemiprotectedRestrictionLevels;
$config = $this->getConfig();
$data = array(
'types' => $wgRestrictionTypes,
'levels' => $wgRestrictionLevels,
'cascadinglevels' => $wgCascadingRestrictionLevels,
'semiprotectedlevels' => $wgSemiprotectedRestrictionLevels,
'types' => $config->get( 'RestrictionTypes' ),
'levels' => $config->get( 'RestrictionLevels' ),
'cascadinglevels' => $config->get( 'CascadingRestrictionLevels' ),
'semiprotectedlevels' => $config->get( 'SemiprotectedRestrictionLevels' ),
);
$this->getResult()->setIndexedTagName( $data['types'], 'type' );
@ -709,9 +706,8 @@ class ApiQuerySiteinfo extends ApiQueryBase {
}
public function appendProtocols( $property ) {
global $wgUrlProtocols;
// Make a copy of the global so we don't try to set the _element key of it - bug 45130
$protocols = array_values( $wgUrlProtocols );
$protocols = array_values( $this->getConfig()->get( 'UrlProtocols' ) );
$this->getResult()->setIndexedTagName( $protocols, 'p' );
return $this->getResult()->addValue( 'query', $property, $protocols );
@ -726,15 +722,15 @@ class ApiQuerySiteinfo extends ApiQueryBase {
}
public function appendSubscribedHooks( $property ) {
global $wgHooks;
$myWgHooks = $wgHooks;
$hooks = $this->getConfig()->get( 'Hooks' );
$myWgHooks = $hooks;
ksort( $myWgHooks );
$data = array();
foreach ( $myWgHooks as $hook => $hooks ) {
foreach ( $myWgHooks as $name => $subscribers ) {
$arr = array(
'name' => $hook,
'subscribers' => array_map( array( 'SpecialVersion', 'arrayToString' ), $hooks ),
'name' => $name,
'subscribers' => array_map( array( 'SpecialVersion', 'arrayToString' ), $subscribers ),
);
$this->getResult()->setIndexedTagName( $arr['subscribers'], 's' );

View file

@ -517,8 +517,8 @@ class ApiQueryContributions extends ApiQueryBase {
}
public function getParamDescription() {
global $wgRCMaxAge;
$p = $this->getModulePrefix();
$RCMaxAge = $this->getConfig()->get( 'RCMaxAge' );
return array(
'limit' => 'The maximum number of contributions to return',
@ -548,7 +548,7 @@ class ApiQueryContributions extends ApiQueryBase {
'show' => array(
"Show only items that meet thse criteria, e.g. non minor edits only: {$p}show=!minor",
"NOTE: If {$p}show=patrolled or {$p}show=!patrolled is set, revisions older than",
"\$wgRCMaxAge ($wgRCMaxAge) won't be shown",
"\$wgRCMaxAge ($RCMaxAge) won't be shown",
),
'tag' => 'Only list revisions tagged with this tag',
'toponly' => 'Only list changes which are the latest revision',

View file

@ -52,7 +52,6 @@ class ApiQueryUserInfo extends ApiQueryBase {
}
protected function getCurrentUserInfo() {
global $wgHiddenPrefs, $wgRCMaxAge;
$user = $this->getUser();
$result = $this->getResult();
$vals = array();
@ -122,7 +121,7 @@ class ApiQueryUserInfo extends ApiQueryBase {
$vals['ratelimits'] = $this->getRateLimits();
}
if ( isset( $this->prop['realname'] ) && !in_array( 'realname', $wgHiddenPrefs ) ) {
if ( isset( $this->prop['realname'] ) && !in_array( 'realname', $this->getConfig()->get( 'HiddenPrefs' ) ) ) {
$vals['realname'] = $user->getRealName();
}
@ -181,7 +180,6 @@ class ApiQueryUserInfo extends ApiQueryBase {
}
protected function getRateLimits() {
global $wgRateLimits;
$user = $this->getUser();
if ( !$user->isPingLimitable() ) {
return array(); // No limits
@ -205,7 +203,7 @@ class ApiQueryUserInfo extends ApiQueryBase {
// Now get the actual limits
$retval = array();
foreach ( $wgRateLimits as $action => $limits ) {
foreach ( $this->getConfig()->get( 'RateLimits' ) as $action => $limits ) {
foreach ( $categories as $cat ) {
if ( isset( $limits[$cat] ) && !is_null( $limits[$cat] ) ) {
$retval[$action][$cat]['hits'] = intval( $limits[$cat][0] );

View file

@ -562,8 +562,6 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
}
public function getResultProperties() {
global $wgLogTypes;
return array(
'' => array(
'type' => array(
@ -632,7 +630,7 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
ApiBase::PROP_NULLABLE => true
),
'logtype' => array(
ApiBase::PROP_TYPE => $wgLogTypes,
ApiBase::PROP_TYPE => $this->getConfig()->get( 'LogTypes' ),
ApiBase::PROP_NULLABLE => true
),
'logaction' => array(

View file

@ -314,15 +314,14 @@ class ApiResult extends ApiBase {
* @since 1.21 int $flags replaced boolean $override
*/
public function addValue( $path, $name, $value, $flags = 0 ) {
global $wgAPIMaxResultSize;
$data = &$this->mData;
if ( $this->mCheckingSize ) {
$newsize = $this->mSize + self::size( $value );
if ( $newsize > $wgAPIMaxResultSize ) {
$maxResultSize = $this->getConfig()->get( 'APIMaxResultSize' );
if ( $newsize > $maxResultSize ) {
$this->setWarning(
"This result was truncated because it would otherwise be larger than the " .
"limit of {$wgAPIMaxResultSize} bytes" );
"limit of {$maxResultSize} bytes" );
return false;
}

View file

@ -34,8 +34,6 @@ class ApiUpload extends ApiBase {
protected $mParams;
public function execute() {
global $wgEnableAsyncUploads;
// Check whether upload is enabled
if ( !UploadBase::isEnabled() ) {
$this->dieUsageMsg( 'uploaddisabled' );
@ -47,7 +45,7 @@ class ApiUpload extends ApiBase {
$this->mParams = $this->extractRequestParams();
$request = $this->getMain()->getRequest();
// Check if async mode is actually supported (jobs done in cli mode)
$this->mParams['async'] = ( $this->mParams['async'] && $wgEnableAsyncUploads );
$this->mParams['async'] = ( $this->mParams['async'] && $this->getConfig()->get( 'EnableAsyncUploads' ) );
// Add the uploaded file to the params array
$this->mParams['file'] = $request->getFileName( 'file' );
$this->mParams['chunk'] = $request->getFileName( 'chunk' );
@ -471,8 +469,6 @@ class ApiUpload extends ApiBase {
* Performs file verification, dies on error.
*/
protected function checkVerification( array $verification ) {
global $wgFileExtensions;
// @todo Move them to ApiBase's message map
switch ( $verification['status'] ) {
// Recoverable errors
@ -504,7 +500,7 @@ class ApiUpload extends ApiBase {
case UploadBase::FILETYPE_BADTYPE:
$extradata = array(
'filetype' => $verification['finalExt'],
'allowed' => array_values( array_unique( $wgFileExtensions ) )
'allowed' => array_values( array_unique( $this->getConfig()->get( 'FileExtensions' ) ) )
);
$this->getResult()->setIndexedTagName( $extradata['allowed'], 'ext' );
@ -666,8 +662,7 @@ class ApiUpload extends ApiBase {
* Checks if asynchronous copy uploads are enabled and throws an error if they are not.
*/
protected function checkAsyncDownloadEnabled() {
global $wgAllowAsyncCopyUploads;
if ( !$wgAllowAsyncCopyUploads ) {
if ( !$this->getConfig()->get( 'AllowAsyncCopyUploads' ) ) {
$this->dieUsage( 'Asynchronous copy uploads disabled', 'asynccopyuploaddisabled' );
}
}