* @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'] );
}
$result = array();
if ( $status->isGood() ) {
// Success!
- global $wgEmailAuthentication;
$user = $status->getValue();
if ( $params['language'] ) {
'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() );
}
}
public function getAllowedParams() {
- global $wgEmailConfirmToEdit;
-
return array(
'name' => array(
ApiBase::PARAM_TYPE => 'user',
'token' => null,
'email' => array(
ApiBase::PARAM_TYPE => 'string',
- ApiBase::PARAM_REQUIRED => $wgEmailConfirmToEdit
+ ApiBase::PARAM_REQUIRED => $this->getConfig()->get( 'EmailConfirmToEdit' ),
),
'realname' => null,
'mailpassword' => array(
);
// '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()
);
$status = $ep->internalAttemptSave( $result, $user->isAllowed( 'bot' ) && $params['bot'] );
$wgRequest = $oldRequest;
- global $wgMaxArticleSize;
switch ( $status->value ) {
case EditPage::AS_HOOK_ERROR:
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' );
}
public function getPossibleErrors() {
- global $wgMaxArticleSize;
-
return array_merge( parent::getPossibleErrors(),
$this->getTitleOrPageIdErrorMessage(),
array(
array( 'spamdetected', 'spam' ),
array( 'summaryrequired' ),
array( 'blockedtext' ),
- array( 'contenttoobig', $wgMaxArticleSize ),
+ array( 'contenttoobig', $this->getConfig()->get( 'MaxArticleSize' ) ),
array( 'noedit-anon' ),
array( 'noedit' ),
array( 'actionthrottledtext' ),
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
'showSizeDiff' => $params['showsizediff'],
) );
- if ( $pager->getLimit() > $wgFeedLimit ) {
- $pager->setLimit( $wgFeedLimit );
+ $feedLimit = $this->getConfig()->get( 'FeedLimit' );
+ if ( $pager->getLimit() > $feedLimit ) {
+ $pager->setLimit( $feedLimit );
}
$feedItems = array();
}
public function getAllowedParams() {
- global $wgFeedClasses;
- $feedFormatNames = array_keys( $wgFeedClasses );
+ $feedFormatNames = array_keys( $this->getConfig()->get( 'FeedClasses' ) );
return array(
'feedformat' => array(
* 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' );
}
}
public function getAllowedParams() {
- global $wgFeedClasses, $wgAllowCategorizedRecentChanges, $wgFeedLimit;
- $feedFormatNames = array_keys( $wgFeedClasses );
+ $config = $this->getConfig();
+ $feedFormatNames = array_keys( $config->get( 'FeedClasses' ) );
$ret = array(
'feedformat' => array(
'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(
'showlinkedto' => false,
);
- if ( $wgAllowCategorizedRecentChanges ) {
+ if ( $config->get( 'AllowCategorizedRecentChanges' ) ) {
$ret += array(
'categories' => array(
ApiBase::PARAM_TYPE => 'string',
* 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' );
}
'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 ) {
$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
$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();
}
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',
$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 ) {
}
public function getAllowedParams() {
- global $wgImportSources;
-
return array(
'token' => array(
ApiBase::PARAM_TYPE => 'string',
ApiBase::PARAM_TYPE => 'upload',
),
'interwikisource' => array(
- ApiBase::PARAM_TYPE => $wgImportSources
+ ApiBase::PARAM_TYPE => $this->getConfig()->get( 'ImportSources' ),
),
'interwikipage' => null,
'fullhistory' => false,
$loginForm = new LoginForm();
$loginForm->setContext( $context );
- global $wgCookiePrefix, $wgPasswordAttemptThrottle;
-
$authRes = $loginForm->authenticateUserData();
switch ( $authRes ) {
case LoginForm::SUCCESS:
$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;
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:
}
}
- 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' );
}
* @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;
}
public function execute() {
- global $wgEnableOpenSearchSuggest, $wgSearchSuggestCacheExpiry;
$params = $this->extractRequestParams();
$search = $params['search'];
$limit = $params['limit'];
$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;
}
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,
'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 '';
}
*/
class ApiProtect extends ApiBase {
public function execute() {
- global $wgRestrictionLevels;
$params = $this->extractRequestParams();
$pageObj = $this->getTitleOrPageId( $params, 'fromdbmaster' );
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] ) );
}
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
$r['linkupdate'] = '';
- if ( $wgEnableParserCache ) {
+ if ( $enableParserCache ) {
$pcache = ParserCache::singleton();
$pcache->save( $p_result, $page, $popts );
}
$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 );
}
if ( !is_null( $params['mime'] ) ) {
- global $wgMiserMode;
- if ( $wgMiserMode ) {
+ if ( $this->getConfig()->get( 'MiserMode' ) ) {
$this->dieUsage( 'MIME search disabled in Miser Mode', 'mimesearchdisabled' );
}
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 );
}
public function getAllowedParams() {
- global $wgRestrictionLevels;
-
return array(
'from' => null,
'continue' => null,
ApiBase::PARAM_ISMULTI => true
),
'prlevel' => array(
- ApiBase::PARAM_TYPE => $wgRestrictionLevels,
+ ApiBase::PARAM_TYPE => $this->getConfig()->get( 'RestrictionLevels' ),
ApiBase::PARAM_ISMULTI => true
),
'prfiltercascade' => array(
}
if ( $params['activeusers'] ) {
- global $wgActiveUserDays;
$this->addTables( 'recentchanges' );
$this->addJoinConds( array( 'recentchanges' => array(
$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 );
}
public function getParamDescription() {
- global $wgActiveUserDays;
-
return array(
'from' => 'The user name to start enumerating from',
'to' => 'The user name to stop enumerating at',
),
'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)"
);
}
);
$this->profileDBOut();
- global $wgAPIMaxDBRows;
- if ( $rowcount > $wgAPIMaxDBRows ) {
+ if ( $rowcount > $this->getConfig()->get( 'APIMaxDBRows' ) ) {
return false;
}
$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' );
}
public function getParamDescription() {
- global $wgBlockCIDRLimit;
+ $blockCIDRLimit = $this->getConfig()->get( 'BlockCIDRLimit' );
$p = $this->getModulePrefix();
return array(
'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',
}
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' ),
// 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'] );
}
public function getParamDescription() {
- global $wgMiserMode;
$p = $this->getModulePrefix();
$desc = array(
'title' => "Which category to enumerate (required). Must include " .
'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",
$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'] );
}
public function getParamDescription() {
- global $wgMiserMode;
$p = $this->getModulePrefix();
$desc = array(
'prop' => array(
'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",
* @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();
}
* @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' );
}
}
: 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' );
$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] );
* 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;
}
) );
$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__ );
$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' );
}
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 ) {
}
public function getAllowedParams( $flags = 0 ) {
- global $wgLogTypes;
-
+ $config = $this->getConfig();
return array(
'prop' => array(
ApiBase::PARAM_ISMULTI => true,
)
),
'type' => array(
- ApiBase::PARAM_TYPE => $wgLogTypes
+ ApiBase::PARAM_TYPE => $config->get( 'LogTypes' )
),
'action' => array(
// validation on request is done in execute()
}
public function getResultProperties() {
- global $wgLogTypes;
-
return array(
'ids' => array(
'logid' => 'integer',
),
'type' => array(
'type' => array(
- ApiBase::PROP_TYPE => $wgLogTypes
+ ApiBase::PROP_TYPE => $this->getConfig()->get( 'LogTypes' )
),
'action' => 'string'
),
}
public function getAllowedParams() {
- global $wgRestrictionLevels;
-
return array(
'namespace' => array(
ApiBase::PARAM_ISMULTI => true,
),
'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,
}
public function getResultProperties() {
- global $wgRestrictionLevels;
-
return array(
'' => array(
'ns' => 'namespace',
),
'level' => array(
'level' => array(
- ApiBase::PROP_TYPE => array_diff( $wgRestrictionLevels, array( '' ) )
+ ApiBase::PROP_TYPE => array_diff( $this->getConfig()->get( 'RestrictionLevels' ), array( '' ) )
)
)
);
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];
}
}
* @param ApiPageSet $resultPageSet
*/
public function run( $resultPageSet = null ) {
- global $wgQueryCacheLimit;
-
$params = $this->extractRequestParams();
$result = $this->getResult();
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 );
}
public function getResultProperties() {
- global $wgLogTypes;
$props = array(
'' => array(
'type' => array(
ApiBase::PROP_NULLABLE => true
),
'logtype' => array(
- ApiBase::PROP_TYPE => $wgLogTypes,
+ ApiBase::PROP_TYPE => $config->get( 'LogTypes' ),
ApiBase::PROP_NULLABLE => true
),
'logaction' => array(
}
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 );
}
public function getAllowedParams() {
- global $wgSearchType;
-
$params = array(
'search' => array(
ApiBase::PARAM_TYPE => 'string',
$alternatives[0] = self::BACKEND_NULL_PARAM;
}
$params['backend'] = array(
- ApiBase::PARAM_DFLT => $wgSearchType,
+ ApiBase::PARAM_DFLT => $this->getConfig()->get( 'SearchType' ),
ApiBase::PARAM_TYPE => $alternatives,
);
}
}
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 ) {
$this->getResult()->setIndexedTagName( $data['externalimages'], 'prefix' );
}
- if ( !$wgDisableLangConversion ) {
+ if ( !$config->get( 'DisableLangConversion' ) ) {
$data['langconversion'] = '';
}
- if ( !$wgDisableTitleConversion ) {
+ if ( !$config->get( 'DisableTitleConversion' ) ) {
$data['titleconversion'] = '';
}
$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 ) {
$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;
}
$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 ) );
}
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 ) {
}
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'
} else {
list( , $lag, $index ) = $lb->getMaxLag();
$data[] = array(
- 'host' => $wgShowHostnames
+ 'host' => $showHostnames
? $lb->getServerName( $index )
: '',
'lag' => intval( $lag )
}
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() );
}
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 ) {
}
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' );
}
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;
}
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();
}
}
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' );
}
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 );
}
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' );
}
public function getParamDescription() {
- global $wgRCMaxAge;
$p = $this->getModulePrefix();
+ $RCMaxAge = $this->getConfig()->get( 'RCMaxAge' );
return array(
'limit' => 'The maximum number of contributions to return',
'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',
}
protected function getCurrentUserInfo() {
- global $wgHiddenPrefs, $wgRCMaxAge;
$user = $this->getUser();
$result = $this->getResult();
$vals = array();
$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();
}
}
protected function getRateLimits() {
- global $wgRateLimits;
$user = $this->getUser();
if ( !$user->isPingLimitable() ) {
return array(); // No limits
// 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] );
}
public function getResultProperties() {
- global $wgLogTypes;
-
return array(
'' => array(
'type' => array(
ApiBase::PROP_NULLABLE => true
),
'logtype' => array(
- ApiBase::PROP_TYPE => $wgLogTypes,
+ ApiBase::PROP_TYPE => $this->getConfig()->get( 'LogTypes' ),
ApiBase::PROP_NULLABLE => true
),
'logaction' => array(
* @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;
}
protected $mParams;
public function execute() {
- global $wgEnableAsyncUploads;
-
// Check whether upload is enabled
if ( !UploadBase::isEnabled() ) {
$this->dieUsageMsg( 'uploaddisabled' );
$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' );
* 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
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' );
* 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' );
}
}