summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>2022-01-10 20:22:20 +0000
committerGerrit Code Review <gerrit@wikimedia.org>2022-01-10 20:22:20 +0000
commit057d6f43923a9b71d9b0f60e4b34c907baf16a5d (patch)
tree34eb55b4046499586181e85e00ebdeef0ab4a465
parentc9207b770b5e0cd35aa0a999d996a8c859d75ffe (diff)
parent47adb6d65a9def579135a3d009fd1b22e99e51ba (diff)
Merge "Refactor global variables to use MediaWikiServices instead"
-rw-r--r--includes/EditPage.php16
-rw-r--r--includes/FauxRequest.php9
-rw-r--r--includes/FeedUtils.php18
-rw-r--r--includes/GitInfo.php21
-rw-r--r--includes/Html.php25
-rw-r--r--includes/Linker.php67
-rw-r--r--includes/MWTimestamp.php4
-rw-r--r--includes/MergeHistory.php6
-rw-r--r--includes/OutputHandler.php9
-rw-r--r--includes/StreamFile.php26
-rw-r--r--includes/WebResponse.php29
-rw-r--r--includes/actions/DeleteAction.php4
-rw-r--r--includes/actions/HistoryAction.php4
-rw-r--r--includes/actions/InfoAction.php5
-rw-r--r--includes/actions/McrUndoAction.php4
-rw-r--r--includes/api/ApiQueryExtLinksUsage.php13
-rw-r--r--includes/block/DatabaseBlock.php10
-rw-r--r--includes/cache/BacklinkCache.php6
-rw-r--r--includes/cache/FileCacheBase.php21
-rw-r--r--includes/cache/LinkCache.php4
-rw-r--r--includes/cache/MessageCache.php18
-rw-r--r--includes/cache/ResourceFileCache.php14
-rw-r--r--includes/changes/AtomFeed.php7
-rw-r--r--includes/changes/ChangesFeed.php14
-rw-r--r--includes/changes/ChangesList.php4
-rw-r--r--includes/changes/ChannelFeed.php11
-rw-r--r--includes/changes/FeedItem.php6
-rw-r--r--includes/changes/RecentChange.php44
-rw-r--r--includes/changetags/ChangeTags.php12
-rw-r--r--includes/collation/Collation.php4
-rw-r--r--includes/config/ConfigFactory.php4
-rw-r--r--includes/content/AbstractContent.php4
-rw-r--r--includes/content/ContentHandler.php7
-rw-r--r--includes/content/CssContentHandler.php4
-rw-r--r--includes/content/JavaScriptContentHandler.php4
-rw-r--r--includes/content/TextContent.php4
-rw-r--r--includes/content/TextContentHandler.php4
-rw-r--r--includes/content/WikitextContent.php8
-rw-r--r--includes/db/MWLBFactory.php5
-rw-r--r--includes/deferred/CdnCacheUpdate.php22
-rw-r--r--includes/deferred/DeferredUpdates.php4
-rw-r--r--includes/exception/MWException.php26
-rw-r--r--includes/exception/MWExceptionRenderer.php42
-rw-r--r--includes/export/WikiExporter.php5
-rw-r--r--includes/export/XmlDumpWriter.php12
-rw-r--r--includes/filerepo/FileRepo.php6
-rw-r--r--includes/filerepo/ForeignAPIRepo.php8
-rw-r--r--includes/filerepo/LocalRepo.php4
-rw-r--r--includes/filerepo/file/File.php37
-rw-r--r--includes/filerepo/file/ForeignAPIFile.php4
-rw-r--r--includes/filerepo/file/LocalFile.php5
-rw-r--r--includes/filerepo/file/MediaFileTrait.php8
-rw-r--r--includes/filerepo/file/UnregisteredLocalFile.php5
-rw-r--r--includes/htmlform/fields/HTMLCheckField.php7
-rw-r--r--includes/htmlform/fields/HTMLRadioField.php7
-rw-r--r--includes/htmlform/fields/HTMLSelectLanguageField.php3
-rw-r--r--includes/http/Http.php8
-rw-r--r--includes/http/MWHttpRequest.php25
-rw-r--r--includes/import/ImportStreamSource.php5
-rw-r--r--includes/import/WikiImporter.php7
-rw-r--r--includes/jobqueue/Job.php7
-rw-r--r--includes/jobqueue/JobQueueGroup.php4
-rw-r--r--includes/jobqueue/jobs/ClearUserWatchlistJob.php4
-rw-r--r--includes/jobqueue/jobs/HTMLCacheUpdateJob.php8
-rw-r--r--includes/jobqueue/jobs/RecentChangesUpdateJob.php15
-rw-r--r--includes/jobqueue/jobs/ThumbnailRenderJob.php22
-rw-r--r--includes/language/Language.php75
-rw-r--r--includes/language/LanguageConverter.php22
-rw-r--r--includes/language/Message.php8
-rw-r--r--includes/languages/LanguageBs.php9
-rw-r--r--includes/languages/LanguageCu.php9
-rw-r--r--includes/languages/LanguageDsb.php9
-rw-r--r--includes/languages/LanguageFi.php7
-rw-r--r--includes/languages/LanguageGa.php9
-rw-r--r--includes/languages/LanguageHsb.php9
-rw-r--r--includes/languages/LanguageHu.php9
-rw-r--r--includes/languages/LanguageHy.php9
-rw-r--r--includes/languages/LanguageKaa.php9
-rw-r--r--includes/languages/LanguageKk_cyrl.php34
-rw-r--r--includes/languages/LanguageLa.php9
-rw-r--r--includes/languages/LanguageOs.php9
-rw-r--r--includes/languages/LanguageSl.php9
-rw-r--r--includes/languages/LanguageTyv.php9
-rw-r--r--includes/logging/LogEventsList.php4
-rw-r--r--includes/logging/LogFormatter.php5
-rw-r--r--includes/logging/LogPage.php39
-rw-r--r--includes/logging/ManualLogEntry.php3
-rw-r--r--includes/logging/RightsLogFormatter.php7
-rw-r--r--includes/mail/UserMailer.php30
-rw-r--r--includes/media/BitmapHandler.php89
-rw-r--r--includes/media/BitmapMetadataHandler.php5
-rw-r--r--includes/media/DjVuHandler.php24
-rw-r--r--includes/media/DjVuImage.php13
-rw-r--r--includes/media/ExifBitmapHandler.php7
-rw-r--r--includes/media/GIFHandler.php5
-rw-r--r--includes/media/JpegHandler.php20
-rw-r--r--includes/media/MediaHandler.php3
-rw-r--r--includes/media/MediaTransformOutput.php13
-rw-r--r--includes/media/SVGReader.php11
-rw-r--r--includes/media/SvgHandler.php36
-rw-r--r--includes/media/ThumbnailImage.php21
-rw-r--r--includes/media/TiffHandler.php13
-rw-r--r--includes/media/TransformationalImageHandler.php16
-rw-r--r--includes/page/Article.php44
-rw-r--r--includes/page/ImagePage.php30
-rw-r--r--includes/page/WikiPage.php27
-rw-r--r--includes/parser/CacheTime.php11
-rw-r--r--includes/parser/LinkHolderArray.php4
-rw-r--r--includes/parser/Parser.php9
-rw-r--r--includes/parser/ParserOutput.php13
-rw-r--r--includes/rcfeed/IRCColourfulRCFeedFormatter.php18
-rw-r--r--includes/rcfeed/MachineReadableRCFeedFormatter.php20
-rw-r--r--includes/resourceloader/ResourceLoader.php9
-rw-r--r--includes/resourceloader/ResourceLoaderImage.php10
-rw-r--r--includes/revisiondelete/RevisionDeleteUser.php6
-rw-r--r--includes/search/SearchHighlighter.php9
-rw-r--r--includes/search/SqlSearchResult.php8
-rw-r--r--includes/search/SqlSearchResultSet.php3
-rw-r--r--includes/session/Session.php15
-rw-r--r--includes/shell/Shell.php4
-rw-r--r--includes/site/Site.php6
-rw-r--r--includes/specials/SpecialUserLogin.php5
-rw-r--r--includes/upload/UploadBase.php114
-rw-r--r--includes/upload/UploadFromUrl.php21
-rw-r--r--includes/upload/UploadStash.php10
-rw-r--r--includes/user/BotPassword.php23
-rw-r--r--includes/user/User.php102
-rw-r--r--includes/user/UserRightsProxy.php11
128 files changed, 1085 insertions, 854 deletions
diff --git a/includes/EditPage.php b/includes/EditPage.php
index 8859c51c068b..fcf3530cc9b1 100644
--- a/includes/EditPage.php
+++ b/includes/EditPage.php
@@ -1258,7 +1258,7 @@ class EditPage implements IEditObject {
* @since 1.21
*/
protected function getContentObject( $def_content = null ) {
- global $wgDisableAnonTalk;
+ $disableAnonTalk = MediaWikiServices::getInstance()->getMainConfig()->get( 'DisableAnonTalk' );
$content = false;
@@ -1401,7 +1401,7 @@ class EditPage implements IEditObject {
$undoIsAnon = $undorev->getUser() ?
!$undorev->getUser()->isRegistered() :
true;
- $undoMessage = ( $undoIsAnon && $wgDisableAnonTalk ) ?
+ $undoMessage = ( $undoIsAnon && $disableAnonTalk ) ?
'undo-summary-anon' :
'undo-summary';
$undoSummary = $this->context->msg(
@@ -1917,8 +1917,8 @@ class EditPage implements IEditObject {
* time.
*/
public function internalAttemptSave( &$result, $markAsBot = false, $markAsMinor = false ) {
- global $wgUseNPPatrol, $wgUseRCPatrol;
-
+ $useNPPatrol = MediaWikiServices::getInstance()->getMainConfig()->get( 'UseNPPatrol' );
+ $useRCPatrol = MediaWikiServices::getInstance()->getMainConfig()->get( 'UseRCPatrol' );
if ( !$this->getHookRunner()->onEditPage__attemptSave( $this ) ) {
wfDebug( "Hook 'EditPage::attemptSave' aborted article saving" );
$status = Status::newFatal( 'hookaborted' );
@@ -2366,7 +2366,7 @@ class EditPage implements IEditObject {
);
}
- $needsPatrol = $wgUseRCPatrol || ( $wgUseNPPatrol && !$this->page->exists() );
+ $needsPatrol = $useRCPatrol || ( $useNPPatrol && !$this->page->exists() );
if ( $needsPatrol && $this->context->getAuthority()
->authorizeWrite( 'autopatrol', $this->getTitle() )
) {
@@ -3802,11 +3802,11 @@ class EditPage implements IEditObject {
* @return string
*/
public static function getCopyrightWarning( $title, $format = 'plain', $langcode = null ) {
- global $wgRightsText;
- if ( $wgRightsText ) {
+ $rightsText = MediaWikiServices::getInstance()->getMainConfig()->get( 'RightsText' );
+ if ( $rightsText ) {
$copywarnMsg = [ 'copyrightwarning',
'[[' . wfMessage( 'copyrightpage' )->inContentLanguage()->text() . ']]',
- $wgRightsText ];
+ $rightsText ];
} else {
$copywarnMsg = [ 'copyrightwarning2',
'[[' . wfMessage( 'copyrightpage' )->inContentLanguage()->text() . ']]' ];
diff --git a/includes/FauxRequest.php b/includes/FauxRequest.php
index 175ed9069924..cb7de524f9f1 100644
--- a/includes/FauxRequest.php
+++ b/includes/FauxRequest.php
@@ -23,6 +23,7 @@
* @file
*/
+use MediaWiki\MediaWikiServices;
use MediaWiki\Session\SessionManager;
/**
@@ -116,8 +117,8 @@ class FauxRequest extends WebRequest {
public function getCookie( $key, $prefix = null, $default = null ) {
if ( $prefix === null ) {
- global $wgCookiePrefix;
- $prefix = $wgCookiePrefix;
+ $cookiePrefix = MediaWikiServices::getInstance()->getMainConfig()->get( 'CookiePrefix' );
+ $prefix = $cookiePrefix;
}
$name = $prefix . $key;
return $this->cookies[$name] ?? $default;
@@ -140,8 +141,8 @@ class FauxRequest extends WebRequest {
*/
public function setCookies( $cookies, $prefix = null ) {
if ( $prefix === null ) {
- global $wgCookiePrefix;
- $prefix = $wgCookiePrefix;
+ $cookiePrefix = MediaWikiServices::getInstance()->getMainConfig()->get( 'CookiePrefix' );
+ $prefix = $cookiePrefix;
}
foreach ( $cookies as $key => $value ) {
$name = $prefix . $key;
diff --git a/includes/FeedUtils.php b/includes/FeedUtils.php
index 659e69c7e3df..4864a63623a9 100644
--- a/includes/FeedUtils.php
+++ b/includes/FeedUtils.php
@@ -42,20 +42,20 @@ class FeedUtils {
* @return bool
*/
public static function checkFeedOutput( $type, $output = null ) {
- global $wgFeed, $wgFeedClasses;
-
+ $feed = MediaWikiServices::getInstance()->getMainConfig()->get( 'Feed' );
+ $feedClasses = MediaWikiServices::getInstance()->getMainConfig()->get( 'FeedClasses' );
if ( $output === null ) {
// Todo update GoogleNewsSitemap and deprecate
global $wgOut;
$output = $wgOut;
}
- if ( !$wgFeed ) {
+ if ( !$feed ) {
$output->addWikiMsg( 'feed-unavailable' );
return false;
}
- if ( !isset( $wgFeedClasses[$type] ) ) {
+ if ( !isset( $feedClasses[$type] ) ) {
$output->addWikiMsg( 'feed-invalid' );
return false;
}
@@ -131,7 +131,7 @@ class FeedUtils {
public static function formatDiffRow2( $title, $oldid, $newid, $timestamp,
$formattedComment, $actiontext = ''
) {
- global $wgFeedDiffCutoff;
+ $feedDiffCutoff = MediaWikiServices::getInstance()->getMainConfig()->get( 'FeedDiffCutoff' );
// log entries
$unwrappedText = implode(
@@ -163,7 +163,7 @@ class FeedUtils {
if ( $oldid ) {
$diffText = '';
// Don't bother generating the diff if we won't be able to show it
- if ( $wgFeedDiffCutoff > 0 ) {
+ if ( $feedDiffCutoff > 0 ) {
$revRecord = $revLookup->getRevisionById( $oldid );
if ( !$revRecord ) {
@@ -190,7 +190,7 @@ class FeedUtils {
}
}
- if ( $wgFeedDiffCutoff <= 0 || ( strlen( $diffText ) > $wgFeedDiffCutoff ) ) {
+ if ( $feedDiffCutoff <= 0 || ( strlen( $diffText ) > $feedDiffCutoff ) ) {
// Omit large diffs
$diffText = self::getDiffLink( $title, $newid, $oldid );
} elseif ( $diffText === false ) {
@@ -207,7 +207,7 @@ class FeedUtils {
}
} else {
$revRecord = $revLookup->getRevisionById( $newid );
- if ( $wgFeedDiffCutoff <= 0 || $revRecord === null ) {
+ if ( $feedDiffCutoff <= 0 || $revRecord === null ) {
$newContent = $contentHandlerFactory
->getContentHandler( $title->getContentModel() )
->makeEmptyContent();
@@ -219,7 +219,7 @@ class FeedUtils {
// only textual content has a "source view".
$text = $newContent->getText();
- if ( $wgFeedDiffCutoff <= 0 || strlen( $text ) > $wgFeedDiffCutoff ) {
+ if ( $feedDiffCutoff <= 0 || strlen( $text ) > $feedDiffCutoff ) {
$html = null;
} else {
$html = nl2br( htmlspecialchars( $text ) );
diff --git a/includes/GitInfo.php b/includes/GitInfo.php
index 3d6cdab5739b..5cc8ce496d22 100644
--- a/includes/GitInfo.php
+++ b/includes/GitInfo.php
@@ -23,6 +23,7 @@
* @file
*/
+use MediaWiki\MediaWikiServices;
use MediaWiki\Shell\Shell;
use Wikimedia\AtEase\AtEase;
@@ -115,9 +116,9 @@ class GitInfo {
* @since 1.24
*/
protected static function getCacheFilePath( $repoDir ) {
- global $IP, $wgGitInfoCacheDirectory;
-
- if ( $wgGitInfoCacheDirectory ) {
+ global $IP;
+ $gitInfoCacheDirectory = MediaWikiServices::getInstance()->getMainConfig()->get( 'GitInfoCacheDirectory' );
+ if ( $gitInfoCacheDirectory ) {
// Convert both $IP and $repoDir to canonical paths to protect against
// $IP having changed between the settings files and runtime.
$realIP = realpath( $IP );
@@ -134,7 +135,7 @@ class GitInfo {
// a filename
$repoName = strtr( $repoName, DIRECTORY_SEPARATOR, '-' );
$fileName = 'info' . $repoName . '.json';
- $cachePath = "{$wgGitInfoCacheDirectory}/{$fileName}";
+ $cachePath = "{$gitInfoCacheDirectory}/{$fileName}";
if ( is_readable( $cachePath ) ) {
return $cachePath;
}
@@ -228,20 +229,20 @@ class GitInfo {
* @return int|bool Commit date (UNIX timestamp) or false
*/
public function getHeadCommitDate() {
- global $wgGitBin;
+ $gitBin = MediaWikiServices::getInstance()->getMainConfig()->get( 'GitBin' );
if ( !isset( $this->cache['headCommitDate'] ) ) {
$date = false;
// Suppress warnings about any open_basedir restrictions affecting $wgGitBin (T74445).
- $isFile = AtEase::quietCall( 'is_file', $wgGitBin );
+ $isFile = AtEase::quietCall( 'is_file', $gitBin );
if ( $isFile &&
- is_executable( $wgGitBin ) &&
+ is_executable( $gitBin ) &&
!Shell::isDisabled() &&
$this->getHead() !== false
) {
$cmd = [
- $wgGitBin,
+ $gitBin,
'show',
'-s',
'--format=format:%ct',
@@ -424,10 +425,10 @@ class GitInfo {
* @return array
*/
protected static function getViewers() {
- global $wgGitRepositoryViewers;
+ $gitRepositoryViewers = MediaWikiServices::getInstance()->getMainConfig()->get( 'GitRepositoryViewers' );
if ( self::$viewers === false ) {
- self::$viewers = $wgGitRepositoryViewers;
+ self::$viewers = $gitRepositoryViewers;
Hooks::runner()->onGitViewers( self::$viewers );
}
diff --git a/includes/Html.php b/includes/Html.php
index 749b4b6f981c..d04c470e5367 100644
--- a/includes/Html.php
+++ b/includes/Html.php
@@ -22,6 +22,7 @@
*
* @file
*/
+
use MediaWiki\MediaWikiServices;
/**
@@ -109,8 +110,9 @@ class Html {
* @return array Modified attributes array
*/
public static function buttonAttributes( array $attrs, array $modifiers = [] ) {
- global $wgUseMediaWikiUIEverywhere;
- if ( $wgUseMediaWikiUIEverywhere ) {
+ $useMediaWikiUIEverywhere = MediaWikiServices::getInstance()
+ ->getMainConfig()->get( 'UseMediaWikiUIEverywhere' );
+ if ( $useMediaWikiUIEverywhere ) {
if ( isset( $attrs['class'] ) ) {
if ( is_array( $attrs['class'] ) ) {
$attrs['class'][] = 'mw-ui-button';
@@ -136,8 +138,9 @@ class Html {
* @return array Modified attributes array
*/
public static function getTextInputAttributes( array $attrs ) {
- global $wgUseMediaWikiUIEverywhere;
- if ( $wgUseMediaWikiUIEverywhere ) {
+ $useMediaWikiUIEverywhere = MediaWikiServices::getInstance()
+ ->getMainConfig()->get( 'UseMediaWikiUIEverywhere' );
+ if ( $useMediaWikiUIEverywhere ) {
if ( isset( $attrs['class'] ) ) {
if ( is_array( $attrs['class'] ) ) {
$attrs['class'][] = 'mw-ui-input';
@@ -993,10 +996,12 @@ class Html {
*/
public static function htmlHeader( array $attribs = [] ) {
$ret = '';
+ $mainConfig = MediaWikiServices::getInstance()->getMainConfig();
+ $html5Version = $mainConfig->get( 'Html5Version' );
+ $mimeType = $mainConfig->get( 'MimeType' );
+ $xhtmlNamespaces = $mainConfig->get( 'XhtmlNamespaces' );
- global $wgHtml5Version, $wgMimeType, $wgXhtmlNamespaces;
-
- $isXHTML = self::isXmlMimeType( $wgMimeType );
+ $isXHTML = self::isXmlMimeType( $mimeType );
if ( $isXHTML ) { // XHTML5
// XML MIME-typed markup should have an xml header.
@@ -1007,15 +1012,15 @@ class Html {
$attribs['xmlns'] = 'http://www.w3.org/1999/xhtml';
// And support custom namespaces
- foreach ( $wgXhtmlNamespaces as $tag => $ns ) {
+ foreach ( $xhtmlNamespaces as $tag => $ns ) {
$attribs["xmlns:$tag"] = $ns;
}
} else { // HTML5
$ret .= "<!DOCTYPE html>\n";
}
- if ( $wgHtml5Version ) {
- $attribs['version'] = $wgHtml5Version;
+ if ( $html5Version ) {
+ $attribs['version'] = $html5Version;
}
$ret .= self::openElement( 'html', $attribs );
diff --git a/includes/Linker.php b/includes/Linker.php
index 3ff6226f8f9f..e00894c5501e 100644
--- a/includes/Linker.php
+++ b/includes/Linker.php
@@ -350,8 +350,8 @@ class Linker {
if ( isset( $handlerParams['height'] ) && $file->isVectorized() ) {
// If its a vector image, and user only specifies height
// we don't want it to be limited by its "normal" width.
- global $wgSVGMaxSize;
- $handlerParams['width'] = $wgSVGMaxSize;
+ $svgMaxSize = MediaWikiServices::getInstance()->getMainConfig()->get( 'SVGMaxSize' );
+ $handlerParams['width'] = $svgMaxSize;
} else {
$handlerParams['width'] = $file->getWidth( $page );
}
@@ -362,24 +362,24 @@ class Linker {
|| isset( $frameParams['frameless'] )
|| !$handlerParams['width']
) {
- global $wgThumbLimits, $wgThumbUpright;
-
- if ( $widthOption === null || !isset( $wgThumbLimits[$widthOption] ) ) {
+ $thumbLimits = MediaWikiServices::getInstance()->getMainConfig()->get( 'ThumbLimits' );
+ $thumbUpright = MediaWikiServices::getInstance()->getMainConfig()->get( 'ThumbUpright' );
+ if ( $widthOption === null || !isset( $thumbLimits[$widthOption] ) ) {
$userOptionsLookup = MediaWikiServices::getInstance()->getUserOptionsLookup();
$widthOption = $userOptionsLookup->getDefaultOption( 'thumbsize' );
}
// Reduce width for upright images when parameter 'upright' is used
if ( isset( $frameParams['upright'] ) && $frameParams['upright'] == 0 ) {
- $frameParams['upright'] = $wgThumbUpright;
+ $frameParams['upright'] = $thumbUpright;
}
// For caching health: If width scaled down due to upright
// parameter, round to full __0 pixel to avoid the creation of a
// lot of odd thumbs.
$prefWidth = isset( $frameParams['upright'] ) ?
- round( $wgThumbLimits[$widthOption] * $frameParams['upright'], -1 ) :
- $wgThumbLimits[$widthOption];
+ round( $thumbLimits[$widthOption] * $frameParams['upright'], -1 ) :
+ $thumbLimits[$widthOption];
// Use width which is smaller: real image width or user preference width
// Unless image is scalable vector.
@@ -801,8 +801,8 @@ class Linker {
* @param array $hp Image parameters
*/
public static function processResponsiveImages( $file, $thumb, $hp ) {
- global $wgResponsiveImages;
- if ( $wgResponsiveImages && $thumb && !$thumb->isError() ) {
+ $responsiveImages = MediaWikiServices::getInstance()->getMainConfig()->get( 'ResponsiveImages' );
+ if ( $responsiveImages && $thumb && !$thumb->isError() ) {
$hp15 = $hp;
$hp15['width'] = round( $hp['width'] * 1.5 );
$hp20 = $hp;
@@ -846,8 +846,10 @@ class Linker {
}
$title = Title::castFromLinkTarget( $title );
-
- global $wgEnableUploads, $wgUploadMissingFileUrl, $wgUploadNavigationUrl;
+ $mainConfig = MediaWikiServices::getInstance()->getMainConfig();
+ $enableUploads = $mainConfig->get( 'EnableUploads' );
+ $uploadMissingFileUrl = $mainConfig->get( 'UploadMissingFileUrl' );
+ $uploadNavigationUrl = $mainConfig->get( 'UploadNavigationUrl' );
if ( $label == '' ) {
$label = $title->getPrefixedText();
}
@@ -867,7 +869,7 @@ class Linker {
$currentExists = $time
&& $repoGroup->findFile( $title ) !== false;
- if ( ( $wgUploadMissingFileUrl || $wgUploadNavigationUrl || $wgEnableUploads )
+ if ( ( $uploadMissingFileUrl || $uploadNavigationUrl || $enableUploads )
&& !$currentExists
) {
if ( $repoGroup->getLocalRepo()->checkRedirect( $title ) ) {
@@ -904,18 +906,19 @@ class Linker {
* @return string Urlencoded URL
*/
protected static function getUploadUrl( $destFile, $query = '' ) {
- global $wgUploadMissingFileUrl, $wgUploadNavigationUrl;
+ $uploadMissingFileUrl = MediaWikiServices::getInstance()->getMainConfig()->get( 'UploadMissingFileUrl' );
+ $uploadNavigationUrl = MediaWikiServices::getInstance()->getMainConfig()->get( 'UploadNavigationUrl' );
$q = 'wpDestFile=' . Title::castFromLinkTarget( $destFile )->getPartialURL();
if ( $query != '' ) {
$q .= '&' . $query;
}
- if ( $wgUploadMissingFileUrl ) {
- return wfAppendQuery( $wgUploadMissingFileUrl, $q );
+ if ( $uploadMissingFileUrl ) {
+ return wfAppendQuery( $uploadMissingFileUrl, $q );
}
- if ( $wgUploadNavigationUrl ) {
- return wfAppendQuery( $wgUploadNavigationUrl, $q );
+ if ( $uploadNavigationUrl ) {
+ return wfAppendQuery( $uploadNavigationUrl, $q );
}
$upload = SpecialPage::getTitleFor( 'Upload' );
@@ -1126,9 +1129,9 @@ class Linker {
'that need to be fixed?' );
return ' ' . wfMessage( 'empty-username' )->parse();
}
-
- global $wgDisableAnonTalk, $wgLang;
- $talkable = !( $wgDisableAnonTalk && $userId == 0 );
+ global $wgLang;
+ $disableAnonTalk = MediaWikiServices::getInstance()->getMainConfig()->get( 'DisableAnonTalk' );
+ $talkable = !( $disableAnonTalk && $userId == 0 );
$blockable = !( $flags & self::TOOL_LINKS_NOBLOCK );
$addEmailLink = $flags & self::TOOL_LINKS_EMAIL && $userId;
@@ -1850,9 +1853,9 @@ class Linker {
* @return int|false|null
*/
public static function getRollbackEditCount( RevisionRecord $revRecord, $verify ) {
- global $wgShowRollbackEditCount;
+ $showRollbackEditCount = MediaWikiServices::getInstance()->getMainConfig()->get( 'ShowRollbackEditCount' );
- if ( !is_int( $wgShowRollbackEditCount ) || !$wgShowRollbackEditCount > 0 ) {
+ if ( !is_int( $showRollbackEditCount ) || !$showRollbackEditCount > 0 ) {
// Nothing has happened, indicate this by returning 'null'
return null;
}
@@ -1873,7 +1876,7 @@ class Linker {
[
'USE INDEX' => [ 'revision' => $revIndex ],
'ORDER BY' => 'rev_timestamp DESC',
- 'LIMIT' => $wgShowRollbackEditCount + 1
+ 'LIMIT' => $showRollbackEditCount + 1
],
$revQuery['joins']
);
@@ -1900,7 +1903,7 @@ class Linker {
$editCount++;
}
- if ( $verify && $editCount <= $wgShowRollbackEditCount && !$moreRevs ) {
+ if ( $verify && $editCount <= $showRollbackEditCount && !$moreRevs ) {
// We didn't find at least $wgShowRollbackEditCount revisions made by the current user
// and there weren't any other revisions. That means that the current user is the only
// editor, so we can't rollback
@@ -1928,8 +1931,8 @@ class Linker {
IContextSource $context = null,
$editCount = false
) {
- global $wgShowRollbackEditCount, $wgMiserMode;
-
+ $showRollbackEditCount = MediaWikiServices::getInstance()->getMainConfig()->get( 'ShowRollbackEditCount' );
+ $miserMode = MediaWikiServices::getInstance()->getMainConfig()->get( 'MiserMode' );
// To config which pages are affected by miser mode
$disableRollbackEditCountSpecialPage = [ 'Recentchanges', 'Watchlist' ];
@@ -1961,7 +1964,7 @@ class Linker {
}
$disableRollbackEditCount = false;
- if ( $wgMiserMode ) {
+ if ( $miserMode ) {
foreach ( $disableRollbackEditCountSpecialPage as $specialPage ) {
if ( $context->getTitle()->isSpecial( $specialPage ) ) {
$disableRollbackEditCount = true;
@@ -1971,16 +1974,16 @@ class Linker {
}
if ( !$disableRollbackEditCount
- && is_int( $wgShowRollbackEditCount )
- && $wgShowRollbackEditCount > 0
+ && is_int( $showRollbackEditCount )
+ && $showRollbackEditCount > 0
) {
if ( !is_numeric( $editCount ) ) {
$editCount = self::getRollbackEditCount( $revRecord, false );
}
- if ( $editCount > $wgShowRollbackEditCount ) {
+ if ( $editCount > $showRollbackEditCount ) {
$html = $context->msg( 'rollbacklinkcount-morethan' )
- ->numParams( $wgShowRollbackEditCount )->parse();
+ ->numParams( $showRollbackEditCount )->parse();
} else {
$html = $context->msg( 'rollbacklinkcount' )->numParams( $editCount )->parse();
}
diff --git a/includes/MWTimestamp.php b/includes/MWTimestamp.php
index d92e69fbc30f..b2f0f128272b 100644
--- a/includes/MWTimestamp.php
+++ b/includes/MWTimestamp.php
@@ -171,9 +171,9 @@ class MWTimestamp extends ConvertibleTimestamp {
* @return MWTimestamp The local instance
*/
public static function getLocalInstance( $ts = false ) {
- global $wgLocaltimezone;
+ $localtimezone = MediaWikiServices::getInstance()->getMainConfig()->get( 'Localtimezone' );
$timestamp = new self( $ts );
- $timestamp->setTimezone( $wgLocaltimezone );
+ $timestamp->setTimezone( $localtimezone );
return $timestamp;
}
}
diff --git a/includes/MergeHistory.php b/includes/MergeHistory.php
index 9ca2ce29e32e..df15f0b64a5d 100644
--- a/includes/MergeHistory.php
+++ b/includes/MergeHistory.php
@@ -25,6 +25,7 @@ use MediaWiki\Content\IContentHandlerFactory;
use MediaWiki\EditPage\SpamChecker;
use MediaWiki\HookContainer\HookContainer;
use MediaWiki\HookContainer\HookRunner;
+use MediaWiki\MediaWikiServices;
use MediaWiki\Page\PageIdentity;
use MediaWiki\Page\WikiPageFactory;
use MediaWiki\Permissions\Authority;
@@ -302,7 +303,8 @@ class MergeHistory {
* @return Status status of the history merge
*/
public function merge( Authority $performer, $reason = '' ) {
- global $wgActorTableSchemaMigrationStage;
+ $actorTableSchemaMigrationStage = MediaWikiServices::getInstance()
+ ->getMainConfig()->get( 'ActorTableSchemaMigrationStage' );
$status = new Status();
@@ -333,7 +335,7 @@ class MergeHistory {
}
// Update denormalized revactor_page too
- if ( $wgActorTableSchemaMigrationStage & SCHEMA_COMPAT_WRITE_TEMP ) {
+ if ( $actorTableSchemaMigrationStage & SCHEMA_COMPAT_WRITE_TEMP ) {
$this->dbw->update(
'revision_actor_temp',
[ 'revactor_page' => $this->dest->getId() ],
diff --git a/includes/OutputHandler.php b/includes/OutputHandler.php
index 845ac9283f5f..7e338dbabdee 100644
--- a/includes/OutputHandler.php
+++ b/includes/OutputHandler.php
@@ -39,8 +39,9 @@ class OutputHandler {
* @return string
*/
public static function handle( $s, $phase ) {
- global $wgDisableOutputCompression, $wgMangleFlashPolicy;
-
+ $config = MediaWikiServices::getInstance()->getMainConfig();
+ $disableOutputCompression = $config->get( 'DisableOutputCompression' );
+ $mangleFlashPolicy = $config->get( 'MangleFlashPolicy' );
// Don't send headers if output is being discarded (T278579)
if ( ( $phase & PHP_OUTPUT_HANDLER_CLEAN ) === PHP_OUTPUT_HANDLER_CLEAN ) {
$logger = LoggerFactory::getInstance( 'output' );
@@ -52,7 +53,7 @@ class OutputHandler {
return $s;
}
- if ( $wgMangleFlashPolicy ) {
+ if ( $mangleFlashPolicy ) {
$s = self::mangleFlashPolicy( $s );
}
@@ -73,7 +74,7 @@ class OutputHandler {
// Compression is not disabled by the application entry point
!defined( 'MW_NO_OUTPUT_COMPRESSION' ) &&
// Compression is not disabled by site configuration
- !$wgDisableOutputCompression
+ !$disableOutputCompression
) {
$s = self::handleGzip( $s );
}
diff --git a/includes/StreamFile.php b/includes/StreamFile.php
index ac7e1f459261..21f4bb21062b 100644
--- a/includes/StreamFile.php
+++ b/includes/StreamFile.php
@@ -1,4 +1,5 @@
<?php
+
/**
* Functions related to the output of file content.
*
@@ -20,6 +21,8 @@
* @file
*/
+use MediaWiki\MediaWikiServices;
+
/**
* Functions related to the output of file content
*/
@@ -70,14 +73,14 @@ class StreamFile {
* @return null|string
*/
public static function contentTypeFromPath( $filename, $safe = true ) {
- global $wgTrivialMimeDetection;
+ $trivialMimeDetection = MediaWikiServices::getInstance()->getMainConfig()->get( 'TrivialMimeDetection' );
$ext = strrchr( $filename, '.' );
$ext = $ext ? strtolower( substr( $ext, 1 ) ) : '';
# trivial detection by file extension,
# used for thumbnails (thumb.php)
- if ( $wgTrivialMimeDetection ) {
+ if ( $trivialMimeDetection ) {
switch ( $ext ) {
case 'gif':
return 'image/gif';
@@ -91,7 +94,7 @@ class StreamFile {
return 'unknown/unknown';
}
- $magic = MediaWiki\MediaWikiServices::getInstance()->getMimeAnalyzer();
+ $magic = MediaWikiServices::getInstance()->getMimeAnalyzer();
// Use the extension only, rather than magic numbers, to avoid opening
// up vulnerabilities due to uploads of files with allowed extensions
// but disallowed types.
@@ -102,18 +105,23 @@ class StreamFile {
* have changed since.
*/
if ( $safe ) {
- global $wgProhibitedFileExtensions, $wgCheckFileExtensions, $wgStrictFileExtensions,
- $wgFileExtensions, $wgVerifyMimeType, $wgMimeTypeExclusions;
+ $mainConfig = MediaWikiServices::getInstance()->getMainConfig();
+ $prohibitedFileExtensions = $mainConfig->get( 'ProhibitedFileExtensions' );
+ $checkFileExtensions = $mainConfig->get( 'CheckFileExtensions' );
+ $strictFileExtensions = $mainConfig->get( 'StrictFileExtensions' );
+ $fileExtensions = $mainConfig->get( 'FileExtensions' );
+ $verifyMimeType = $mainConfig->get( 'VerifyMimeType' );
+ $mimeTypeExclusions = $mainConfig->get( 'MimeTypeExclusions' );
list( , $extList ) = UploadBase::splitExtensions( $filename );
- if ( UploadBase::checkFileExtensionList( $extList, $wgProhibitedFileExtensions ) ) {
+ if ( UploadBase::checkFileExtensionList( $extList, $prohibitedFileExtensions ) ) {
return 'unknown/unknown';
}
- if ( $wgCheckFileExtensions && $wgStrictFileExtensions
- && !UploadBase::checkFileExtensionList( $extList, $wgFileExtensions )
+ if ( $checkFileExtensions && $strictFileExtensions
+ && !UploadBase::checkFileExtensionList( $extList, $fileExtensions )
) {
return 'unknown/unknown';
}
- if ( $wgVerifyMimeType && in_array( strtolower( $type ), $wgMimeTypeExclusions ) ) {
+ if ( $verifyMimeType && in_array( strtolower( $type ), $mimeTypeExclusions ) ) {
return 'unknown/unknown';
}
}
diff --git a/includes/WebResponse.php b/includes/WebResponse.php
index 113e0c819ff7..5d35baad5c7a 100644
--- a/includes/WebResponse.php
+++ b/includes/WebResponse.php
@@ -20,6 +20,7 @@
* @file
*/
+use MediaWiki\MediaWikiServices;
use Wikimedia\Http\SetCookieCompat;
/**
@@ -139,21 +140,25 @@ class WebResponse {
* @since 1.22 Replaced $prefix, $domain, and $forceSecure with $options
*/
public function setCookie( $name, $value, $expire = 0, $options = [] ) {
- global $wgCookiePath, $wgCookiePrefix, $wgCookieDomain;
- global $wgCookieSecure, $wgCookieExpiration, $wgCookieHttpOnly;
- global $wgUseSameSiteLegacyCookies;
-
+ $mainConfig = MediaWikiServices::getInstance()->getMainConfig();
+ $cookiePath = $mainConfig->get( 'CookiePath' );
+ $cookiePrefix = $mainConfig->get( 'CookiePrefix' );
+ $cookieDomain = $mainConfig->get( 'CookieDomain' );
+ $cookieSecure = $mainConfig->get( 'CookieSecure' );
+ $cookieExpiration = $mainConfig->get( 'CookieExpiration' );
+ $cookieHttpOnly = $mainConfig->get( 'CookieHttpOnly' );
+ $useSameSiteLegacyCookies = $mainConfig->get( 'UseSameSiteLegacyCookies' );
$options = array_filter( $options, static function ( $a ) {
return $a !== null;
} ) + [
- 'prefix' => $wgCookiePrefix,
- 'domain' => $wgCookieDomain,
- 'path' => $wgCookiePath,
- 'secure' => $wgCookieSecure,
- 'httpOnly' => $wgCookieHttpOnly,
+ 'prefix' => $cookiePrefix,
+ 'domain' => $cookieDomain,
+ 'path' => $cookiePath,
+ 'secure' => $cookieSecure,
+ 'httpOnly' => $cookieHttpOnly,
'raw' => false,
'sameSite' => '',
- 'sameSiteLegacy' => $wgUseSameSiteLegacyCookies
+ 'sameSiteLegacy' => $useSameSiteLegacyCookies
];
if ( strcasecmp( $options['sameSite'], 'none' ) === 0
@@ -167,8 +172,8 @@ class WebResponse {
if ( $expire === null ) {
$expire = 0; // Session cookie
- } elseif ( $expire == 0 && $wgCookieExpiration != 0 ) {
- $expire = time() + $wgCookieExpiration;
+ } elseif ( $expire == 0 && $cookieExpiration != 0 ) {
+ $expire = time() + $cookieExpiration;
}
if ( self::$disableForPostSend ) {
diff --git a/includes/actions/DeleteAction.php b/includes/actions/DeleteAction.php
index 5092192135c5..075527acb82f 100644
--- a/includes/actions/DeleteAction.php
+++ b/includes/actions/DeleteAction.php
@@ -198,11 +198,11 @@ class DeleteAction extends FormlessAction {
);
if ( $title->isBigDeletion() ) {
- global $wgDeleteRevisionsLimit;
+ $deleteRevisionsLimit = MediaWikiServices::getInstance()->getMainConfig()->get( 'DeleteRevisionsLimit' );
$context->getOutput()->wrapWikiMsg( "<div class='error'>\n$1\n</div>\n",
[
'delete-warning-toobig',
- $context->getLanguage()->formatNum( $wgDeleteRevisionsLimit )
+ $context->getLanguage()->formatNum( $deleteRevisionsLimit )
]
);
}
diff --git a/includes/actions/HistoryAction.php b/includes/actions/HistoryAction.php
index 813fb0156b96..1078f13a518b 100644
--- a/includes/actions/HistoryAction.php
+++ b/includes/actions/HistoryAction.php
@@ -203,8 +203,8 @@ class HistoryAction extends FormlessAction {
// Fail nicely if article doesn't exist.
if ( !$this->getWikiPage()->exists() ) {
- global $wgSend404Code;
- if ( $wgSend404Code ) {
+ $send404Code = MediaWikiServices::getInstance()->getMainConfig()->get( 'Send404Code' );
+ if ( $send404Code ) {
$out->setStatusCode( 404 );
}
$out->addWikiMsg( 'nohistory' );
diff --git a/includes/actions/InfoAction.php b/includes/actions/InfoAction.php
index 0c8b57494379..4f777a992035 100644
--- a/includes/actions/InfoAction.php
+++ b/includes/actions/InfoAction.php
@@ -927,7 +927,8 @@ class InfoAction extends FormlessAction {
self::getCacheKey( $cache, $page->getTitle(), $page->getLatest() ),
WANObjectCache::TTL_WEEK,
function ( $oldValue, &$ttl, &$setOpts ) use ( $page, $config, $fname ) {
- global $wgActorTableSchemaMigrationStage;
+ $actorTableSchemaMigrationStage = MediaWikiServices::getInstance()
+ ->getMainConfig()->get( 'ActorTableSchemaMigrationStage' );
$title = $page->getTitle();
$id = $title->getArticleID();
@@ -939,7 +940,7 @@ class InfoAction extends FormlessAction {
);
$setOpts += Database::getCacheSetOptions( $dbr, $dbrWatchlist );
- if ( $wgActorTableSchemaMigrationStage & SCHEMA_COMPAT_READ_NEW ) {
+ if ( $actorTableSchemaMigrationStage & SCHEMA_COMPAT_READ_NEW ) {
$tables = [ 'revision' ];
$field = 'rev_actor';
$pageField = 'rev_page';
diff --git a/includes/actions/McrUndoAction.php b/includes/actions/McrUndoAction.php
index fb241e65b97f..472271008c04 100644
--- a/includes/actions/McrUndoAction.php
+++ b/includes/actions/McrUndoAction.php
@@ -340,7 +340,7 @@ class McrUndoAction extends FormAction {
}
public function onSubmit( $data ) {
- global $wgUseRCPatrol;
+ $useRCPatrol = MediaWikiServices::getInstance()->getMainConfig()->get( 'UseRCPatrol' );
if ( !$this->getRequest()->getCheck( 'wpSave' ) ) {
// Diff or preview
@@ -409,7 +409,7 @@ class McrUndoAction extends FormAction {
$updater->markAsRevert( EditResult::REVERT_UNDO, $this->undo, $this->undoafter );
- if ( $wgUseRCPatrol && $this->getContext()->getAuthority()
+ if ( $useRCPatrol && $this->getContext()->getAuthority()
->authorizeWrite( 'autopatrol', $this->getTitle() )
) {
$updater->setRcPatrolStatus( RecentChange::PRC_AUTOPATROLLED );
diff --git a/includes/api/ApiQueryExtLinksUsage.php b/includes/api/ApiQueryExtLinksUsage.php
index 4f3d4d3ff8b6..30bdd2fa54df 100644
--- a/includes/api/ApiQueryExtLinksUsage.php
+++ b/includes/api/ApiQueryExtLinksUsage.php
@@ -1,4 +1,5 @@
<?php
+
/**
* Copyright © 2006 Yuri Astrakhan "<Firstname><Lastname>@gmail.com"
*
@@ -20,6 +21,8 @@
* @file
*/
+use MediaWiki\MediaWikiServices;
+
/**
* @ingroup API
*/
@@ -249,9 +252,9 @@ class ApiQueryExtLinksUsage extends ApiQueryGeneratorBase {
}
public static function prepareProtocols() {
- global $wgUrlProtocols;
+ $urlProtocols = MediaWikiServices::getInstance()->getMainConfig()->get( 'UrlProtocols' );
$protocols = [ '' ];
- foreach ( $wgUrlProtocols as $p ) {
+ foreach ( $urlProtocols as $p ) {
if ( $p !== '//' ) {
$protocols[] = substr( $p, 0, strpos( $p, ':' ) );
}
@@ -262,9 +265,9 @@ class ApiQueryExtLinksUsage extends ApiQueryGeneratorBase {
public static function getProtocolPrefix( $protocol ) {
// Find the right prefix
- global $wgUrlProtocols;
- if ( $protocol && !in_array( $protocol, $wgUrlProtocols ) ) {
- foreach ( $wgUrlProtocols as $p ) {
+ $urlProtocols = MediaWikiServices::getInstance()->getMainConfig()->get( 'UrlProtocols' );
+ if ( $protocol && !in_array( $protocol, $urlProtocols ) ) {
+ foreach ( $urlProtocols as $p ) {
if ( substr( $p, 0, strlen( $protocol ) ) === $protocol ) {
$protocol = $p;
break;
diff --git a/includes/block/DatabaseBlock.php b/includes/block/DatabaseBlock.php
index 07ed7b108b2c..80ec41961bb9 100644
--- a/includes/block/DatabaseBlock.php
+++ b/includes/block/DatabaseBlock.php
@@ -417,11 +417,11 @@ class DatabaseBlock extends AbstractBlock {
* @return string
*/
protected static function getIpFragment( $hex ) {
- global $wgBlockCIDRLimit;
+ $blockCIDRLimit = MediaWikiServices::getInstance()->getMainConfig()->get( 'BlockCIDRLimit' );
if ( substr( $hex, 0, 3 ) == 'v6-' ) {
- return 'v6-' . substr( substr( $hex, 3 ), 0, floor( $wgBlockCIDRLimit['IPv6'] / 4 ) );
+ return 'v6-' . substr( substr( $hex, 3 ), 0, floor( $blockCIDRLimit['IPv6'] / 4 ) );
} else {
- return substr( $hex, 0, floor( $wgBlockCIDRLimit['IPv4'] / 4 ) );
+ return substr( $hex, 0, floor( $blockCIDRLimit['IPv4'] / 4 ) );
}
}
@@ -812,9 +812,9 @@ class DatabaseBlock extends AbstractBlock {
* @return string
*/
public static function getAutoblockExpiry( $timestamp ) {
- global $wgAutoblockExpiry;
+ $autoblockExpiry = MediaWikiServices::getInstance()->getMainConfig()->get( 'AutoblockExpiry' );
- return wfTimestamp( TS_MW, (int)wfTimestamp( TS_UNIX, $timestamp ) + $wgAutoblockExpiry );
+ return wfTimestamp( TS_MW, (int)wfTimestamp( TS_UNIX, $timestamp ) + $autoblockExpiry );
}
/**
diff --git a/includes/cache/BacklinkCache.php b/includes/cache/BacklinkCache.php
index 91d4bab8d0bb..140a1f1d3360 100644
--- a/includes/cache/BacklinkCache.php
+++ b/includes/cache/BacklinkCache.php
@@ -356,7 +356,7 @@ class BacklinkCache {
* @return int
*/
public function getNumLinks( $table, $max = INF ) {
- global $wgUpdateRowsPerJob;
+ $updateRowsPerJob = MediaWikiServices::getInstance()->getMainConfig()->get( 'UpdateRowsPerJob' );
// 1) try partition cache ...
if ( isset( $this->partitionCache[$table] ) ) {
@@ -393,8 +393,8 @@ class BacklinkCache {
if ( is_infinite( $max ) ) { // no limit at all
// Use partition() since it will batch the query and skip the JOIN.
// Use $wgUpdateRowsPerJob just to encourage cache reuse for jobs.
- $this->partition( $table, $wgUpdateRowsPerJob ); // updates $this->partitionCache
- return $this->partitionCache[$table][$wgUpdateRowsPerJob]['numRows'];
+ $this->partition( $table, $updateRowsPerJob ); // updates $this->partitionCache
+ return $this->partitionCache[$table][$updateRowsPerJob]['numRows'];
} else {
// Fetch the full title info, since the caller will likely need it next
$count = iterator_count( $this->getLinkPages( $table, false, false, $max ) );
diff --git a/includes/cache/FileCacheBase.php b/includes/cache/FileCacheBase.php
index 617a46558d51..7669f0b97284 100644
--- a/includes/cache/FileCacheBase.php
+++ b/includes/cache/FileCacheBase.php
@@ -21,6 +21,7 @@
* @ingroup Cache
*/
+use MediaWiki\MediaWikiServices;
use Wikimedia\IPUtils;
/**
@@ -42,9 +43,9 @@ abstract class FileCacheBase {
private const MISS_TTL_SEC = 3600; // how many seconds ago is "recent"
protected function __construct() {
- global $wgUseGzip;
+ $useGzip = MediaWikiServices::getInstance()->getMainConfig()->get( 'UseGzip' );
- $this->mUseGzip = (bool)$wgUseGzip;
+ $this->mUseGzip = (bool)$useGzip;
}
/**
@@ -52,9 +53,9 @@ abstract class FileCacheBase {
* @return string
*/
final protected function baseCacheDirectory() {
- global $wgFileCacheDirectory;
+ $fileCacheDirectory = MediaWikiServices::getInstance()->getMainConfig()->get( 'FileCacheDirectory' );
- return $wgFileCacheDirectory;
+ return $fileCacheDirectory;
}
/**
@@ -117,16 +118,16 @@ abstract class FileCacheBase {
* @return bool
*/
public function isCacheGood( $timestamp = '' ) {
- global $wgCacheEpoch;
+ $cacheEpoch = MediaWikiServices::getInstance()->getMainConfig()->get( 'CacheEpoch' );
if ( !$this->isCached() ) {
return false;
}
$cachetime = $this->cacheTimestamp();
- $good = ( $timestamp <= $cachetime && $wgCacheEpoch <= $cachetime );
+ $good = ( $timestamp <= $cachetime && $cacheEpoch <= $cachetime );
wfDebug( __METHOD__ .
- ": cachetime $cachetime, touched '{$timestamp}' epoch {$wgCacheEpoch}, good $good" );
+ ": cachetime $cachetime, touched '{$timestamp}' epoch {$cacheEpoch}, good $good" );
return $good;
}
@@ -212,12 +213,12 @@ abstract class FileCacheBase {
* @return string
*/
protected function hashSubdirectory() {
- global $wgFileCacheDepth;
+ $fileCacheDepth = MediaWikiServices::getInstance()->getMainConfig()->get( 'FileCacheDepth' );
$subdir = '';
- if ( $wgFileCacheDepth > 0 ) {
+ if ( $fileCacheDepth > 0 ) {
$hash = md5( $this->mKey );
- for ( $i = 1; $i <= $wgFileCacheDepth; $i++ ) {
+ for ( $i = 1; $i <= $fileCacheDepth; $i++ ) {
$subdir .= substr( $hash, 0, $i ) . '/';
}
}
diff --git a/includes/cache/LinkCache.php b/includes/cache/LinkCache.php
index c852525529fb..9459b03473ae 100644
--- a/includes/cache/LinkCache.php
+++ b/includes/cache/LinkCache.php
@@ -382,7 +382,7 @@ class LinkCache implements LoggerAwareInterface {
* @return array
*/
public static function getSelectFields() {
- global $wgPageLanguageUseDB;
+ $pageLanguageUseDB = MediaWikiServices::getInstance()->getMainConfig()->get( 'PageLanguageUseDB' );
$fields = array_merge(
PageStoreRecord::REQUIRED_FIELDS,
@@ -393,7 +393,7 @@ class LinkCache implements LoggerAwareInterface {
]
);
- if ( $wgPageLanguageUseDB ) {
+ if ( $pageLanguageUseDB ) {
$fields[] = 'page_lang';
}
diff --git a/includes/cache/MessageCache.php b/includes/cache/MessageCache.php
index 481ad724ce3f..195fcc57157f 100644
--- a/includes/cache/MessageCache.php
+++ b/includes/cache/MessageCache.php
@@ -476,8 +476,8 @@ class MessageCache implements LoggerAwareInterface {
* @return array Loaded messages for storing in caches
*/
protected function loadFromDB( $code, $mode = null ) {
- global $wgMaxMsgCacheEntrySize, $wgAdaptiveMessageCache;
-
+ $maxMsgCacheEntrySize = MediaWikiServices::getInstance()->getMainConfig()->get( 'MaxMsgCacheEntrySize' );
+ $adaptiveMessageCache = MediaWikiServices::getInstance()->getMainConfig()->get( 'AdaptiveMessageCache' );
// (T164666) The query here performs really poorly on WMF's
// contributions replicas. We don't have a way to say "any group except
// contributions", so for the moment let's specify 'api'.
@@ -487,7 +487,7 @@ class MessageCache implements LoggerAwareInterface {
$cache = [];
$mostused = []; // list of "<cased message key>/<code>"
- if ( $wgAdaptiveMessageCache && $code !== $this->contLangCode ) {
+ if ( $adaptiveMessageCache && $code !== $this->contLangCode ) {
if ( !$this->cache->has( $this->contLangCode ) ) {
$this->load( $this->contLangCode );
}
@@ -517,12 +517,12 @@ class MessageCache implements LoggerAwareInterface {
$res = $dbr->select(
'page',
[ 'page_title', 'page_latest' ],
- array_merge( $conds, [ 'page_len > ' . intval( $wgMaxMsgCacheEntrySize ) ] ),
+ array_merge( $conds, [ 'page_len > ' . intval( $maxMsgCacheEntrySize ) ] ),
__METHOD__ . "($code)-big"
);
foreach ( $res as $row ) {
// Include entries/stubs for all keys in $mostused in adaptive mode
- if ( $wgAdaptiveMessageCache || $this->isMainCacheable( $row->page_title )
+ if ( $adaptiveMessageCache || $this->isMainCacheable( $row->page_title )
) {
$cache[$row->page_title] = '!TOO BIG';
}
@@ -554,7 +554,7 @@ class MessageCache implements LoggerAwareInterface {
$revQuery['tables'],
$revQuery['fields'],
array_merge( $conds, [
- 'page_len <= ' . intval( $wgMaxMsgCacheEntrySize ),
+ 'page_len <= ' . intval( $maxMsgCacheEntrySize ),
'page_latest = rev_id' // get the latest revision only
] ),
__METHOD__ . "($code)-small",
@@ -568,7 +568,7 @@ class MessageCache implements LoggerAwareInterface {
$revisions = $result->isOK() ? $result->getValue() : [];
foreach ( $res as $row ) {
// Include entries/stubs for all keys in $mostused in adaptive mode
- if ( $wgAdaptiveMessageCache || $this->isMainCacheable( $row->page_title )
+ if ( $adaptiveMessageCache || $this->isMainCacheable( $row->page_title )
) {
try {
$rev = $revisions[$row->rev_id] ?? null;
@@ -698,7 +698,7 @@ class MessageCache implements LoggerAwareInterface {
* @throws MWException
*/
public function refreshAndReplaceInternal( $code, array $replacements ) {
- global $wgMaxMsgCacheEntrySize;
+ $maxMsgCacheEntrySize = MediaWikiServices::getInstance()->getMainConfig()->get( 'MaxMsgCacheEntrySize' );
// Allow one caller at a time to avoid race conditions
$scopedLock = $this->getReentrantScopedLock(
@@ -734,7 +734,7 @@ class MessageCache implements LoggerAwareInterface {
// Note that if $text is false, then $cache should have a !NONEXISTANT entry
if ( !is_string( $text ) ) {
$cache[$title] = '!NONEXISTENT';
- } elseif ( strlen( $text ) > $wgMaxMsgCacheEntrySize ) {
+ } elseif ( strlen( $text ) > $maxMsgCacheEntrySize ) {
$cache[$title] = '!TOO BIG';
$newBigTitles[$title] = $page->getLatest();
} else {
diff --git a/includes/cache/ResourceFileCache.php b/includes/cache/ResourceFileCache.php
index 4f7cb2580ff4..f8800db575ad 100644
--- a/includes/cache/ResourceFileCache.php
+++ b/includes/cache/ResourceFileCache.php
@@ -1,4 +1,5 @@
<?php
+
/**
* ResourceLoader request result caching in the file system.
*
@@ -21,6 +22,8 @@
* @ingroup Cache
*/
+use MediaWiki\MediaWikiServices;
+
/**
* ResourceLoader request result caching in the file system.
*
@@ -64,8 +67,11 @@ class ResourceFileCache extends FileCacheBase {
* @return bool
*/
public static function useFileCache( ResourceLoaderContext $context ) {
- global $wgUseFileCache, $wgDefaultSkin, $wgLanguageCode;
- if ( !$wgUseFileCache ) {
+ $mainConfig = MediaWikiServices::getInstance()->getMainConfig();
+ $useFileCache = $mainConfig->get( 'UseFileCache' );
+ $defaultSkin = $mainConfig->get( 'DefaultSkin' );
+ $languageCode = $mainConfig->get( 'LanguageCode' );
+ if ( !$useFileCache ) {
return false;
}
// Get all query values
@@ -74,9 +80,9 @@ class ResourceFileCache extends FileCacheBase {
if ( in_array( $query, [ 'modules', 'image', 'variant', 'version' ] ) ) {
// Use file cache regardless of the value of this parameter
continue;
- } elseif ( $query === 'skin' && $val === $wgDefaultSkin ) {
+ } elseif ( $query === 'skin' && $val === $defaultSkin ) {
continue;
- } elseif ( $query === 'lang' && $val === $wgLanguageCode ) {
+ } elseif ( $query === 'lang' && $val === $languageCode ) {
continue;
} elseif ( $query === 'only' && in_array( $val, [ 'styles', 'scripts' ] ) ) {
continue;
diff --git a/includes/changes/AtomFeed.php b/includes/changes/AtomFeed.php
index 43155193c04d..c917839c452d 100644
--- a/includes/changes/AtomFeed.php
+++ b/includes/changes/AtomFeed.php
@@ -1,4 +1,5 @@
<?php
+
/**
* Copyright © 2004 Brion Vibber <brion@pobox.com>
* https://www.mediawiki.org/
@@ -21,6 +22,8 @@
* @file
*/
+use MediaWiki\MediaWikiServices;
+
/**
* Generate an Atom feed.
*
@@ -87,13 +90,13 @@ class AtomFeed extends ChannelFeed {
* @param FeedItem $item
*/
public function outItem( $item ) {
- global $wgMimeType;
+ $mimeType = MediaWikiServices::getInstance()->getMainConfig()->get( 'MimeType' );
// Manually escaping rather than letting Mustache do it because Mustache
// uses htmlentities, which does not work with XML
$templateParams = [
"uniqueID" => $item->getUniqueID(),
"title" => $item->getTitle(),
- "mimeType" => $this->xmlEncode( $wgMimeType ),
+ "mimeType" => $this->xmlEncode( $mimeType ),
"url" => $this->xmlEncode( wfExpandUrl( $item->getUrlUnescaped(), PROTO_CURRENT ) ),
"date" => $this->xmlEncode( $this->formatTime( $item->getDate() ) ),
"description" => $item->getDescription(),
diff --git a/includes/changes/ChangesFeed.php b/includes/changes/ChangesFeed.php
index a62c52115eee..3f11fec8ebd0 100644
--- a/includes/changes/ChangesFeed.php
+++ b/includes/changes/ChangesFeed.php
@@ -48,19 +48,21 @@ class ChangesFeed {
* @return ChannelFeed|bool ChannelFeed subclass or false on failure
*/
public function getFeedObject( $title, $description, $url ) {
- global $wgSitename, $wgLanguageCode, $wgFeedClasses;
-
- if ( !isset( $wgFeedClasses[$this->format] ) ) {
+ $mainConfig = MediaWikiServices::getInstance()->getMainConfig();
+ $sitename = $mainConfig->get( 'Sitename' );
+ $languageCode = $mainConfig->get( 'LanguageCode' );
+ $feedClasses = $mainConfig->get( 'FeedClasses' );
+ if ( !isset( $feedClasses[$this->format] ) ) {
return false;
}
- if ( !array_key_exists( $this->format, $wgFeedClasses ) ) {
+ if ( !array_key_exists( $this->format, $feedClasses ) ) {
// falling back to atom
$this->format = 'atom';
}
- $feedTitle = "$wgSitename - {$title} [$wgLanguageCode]";
- return new $wgFeedClasses[$this->format](
+ $feedTitle = "{$sitename} - {$title} [{$languageCode}]";
+ return new $feedClasses[$this->format](
$feedTitle, htmlspecialchars( $description ), $url );
}
diff --git a/includes/changes/ChangesList.php b/includes/changes/ChangesList.php
index c8043187da12..1521dbeb209b 100644
--- a/includes/changes/ChangesList.php
+++ b/includes/changes/ChangesList.php
@@ -275,9 +275,9 @@ class ChangesList extends ContextSource {
static $flagInfos = null;
if ( $flagInfos === null ) {
- global $wgRecentChangesFlags;
+ $recentChangesFlags = MediaWikiServices::getInstance()->getMainConfig()->get( 'RecentChangesFlags' );
$flagInfos = [];
- foreach ( $wgRecentChangesFlags as $key => $value ) {
+ foreach ( $recentChangesFlags as $key => $value ) {
$flagInfos[$key]['letter'] = $value['letter'];
$flagInfos[$key]['title'] = $value['title'];
// Allow customized class name, fall back to flag name
diff --git a/includes/changes/ChannelFeed.php b/includes/changes/ChannelFeed.php
index 4b5a1c61c43a..6f09271a66ae 100644
--- a/includes/changes/ChannelFeed.php
+++ b/includes/changes/ChannelFeed.php
@@ -1,4 +1,5 @@
<?php
+
/**
* Copyright © 2004 Brion Vibber <brion@pobox.com>
* https://www.mediawiki.org/
@@ -21,6 +22,8 @@
* @file
*/
+use MediaWiki\MediaWikiServices;
+
/**
* Class to support the outputting of syndication feeds in Atom and RSS format.
*
@@ -87,19 +90,19 @@ abstract class ChannelFeed extends FeedItem {
* but can also be called separately.
*/
public function httpHeaders() {
- global $wgOut, $wgVaryOnXFP;
-
+ global $wgOut;
+ $varyOnXFP = MediaWikiServices::getInstance()->getMainConfig()->get( 'VaryOnXFP' );
# We take over from $wgOut, excepting its cache header info
$wgOut->disable();
$mimetype = $this->contentType();
header( "Content-type: $mimetype; charset=UTF-8" );
// Set a sensible filename
- $mimeAnalyzer = MediaWiki\MediaWikiServices::getInstance()->getMimeAnalyzer();
+ $mimeAnalyzer = MediaWikiServices::getInstance()->getMimeAnalyzer();
$ext = $mimeAnalyzer->getExtensionFromMimeTypeOrNull( $mimetype ) ?? 'xml';
header( "Content-Disposition: inline; filename=\"feed.{$ext}\"" );
- if ( $wgVaryOnXFP ) {
+ if ( $varyOnXFP ) {
$wgOut->addVaryHeader( 'X-Forwarded-Proto' );
}
$wgOut->sendCacheControl();
diff --git a/includes/changes/FeedItem.php b/includes/changes/FeedItem.php
index cb3f9e67e648..b2cf523af06b 100644
--- a/includes/changes/FeedItem.php
+++ b/includes/changes/FeedItem.php
@@ -21,6 +21,8 @@
* @file
*/
+use MediaWiki\MediaWikiServices;
+
/**
* @defgroup Feed Feed
*/
@@ -162,8 +164,8 @@ class FeedItem {
* @return string
*/
public function getLanguage() {
- global $wgLanguageCode;
- return LanguageCode::bcp47( $wgLanguageCode );
+ $languageCode = MediaWikiServices::getInstance()->getMainConfig()->get( 'LanguageCode' );
+ return LanguageCode::bcp47( $languageCode );
}
/**
diff --git a/includes/changes/RecentChange.php b/includes/changes/RecentChange.php
index fd2ba52561e3..aa8aa480f8fa 100644
--- a/includes/changes/RecentChange.php
+++ b/includes/changes/RecentChange.php
@@ -19,6 +19,7 @@
*
* @file
*/
+
use MediaWiki\ChangeTags\Taggable;
use MediaWiki\MediaWikiServices;
use MediaWiki\Page\PageIdentity;
@@ -403,14 +404,16 @@ class RecentChange implements Taggable {
* @param bool $send self::SEND_FEED or self::SEND_NONE
*/
public function save( $send = self::SEND_FEED ) {
- global $wgPutIPinRC, $wgUseEnotif, $wgShowUpdatedMarker;
-
+ $mainConfig = MediaWikiServices::getInstance()->getMainConfig();
+ $putIPinRC = $mainConfig->get( 'PutIPinRC' );
+ $useEnotif = $mainConfig->get( 'UseEnotif' );
+ $showUpdatedMarker = $mainConfig->get( 'ShowUpdatedMarker' );
$dbw = wfGetDB( DB_PRIMARY );
if ( !is_array( $this->mExtra ) ) {
$this->mExtra = [];
}
- if ( !$wgPutIPinRC ) {
+ if ( !$putIPinRC ) {
$this->mAttribs['rc_ip'] = '';
}
@@ -499,7 +502,7 @@ class RecentChange implements Taggable {
}
# E-mail notifications
- if ( $wgUseEnotif || $wgShowUpdatedMarker ) {
+ if ( $useEnotif || $showUpdatedMarker ) {
$userFactory = MediaWikiServices::getInstance()->getUserFactory();
$editor = $userFactory->newFromUserIdentity( $this->getPerformerIdentity() );
$page = $this->getPage();
@@ -548,9 +551,9 @@ class RecentChange implements Taggable {
* @param array|null $feeds Optional feeds to send to, defaults to $wgRCFeeds
*/
public function notifyRCFeeds( array $feeds = null ) {
- global $wgRCFeeds;
+ $rcFeeds = MediaWikiServices::getInstance()->getMainConfig()->get( 'RCFeeds' );
if ( $feeds === null ) {
- $feeds = $wgRCFeeds;
+ $feeds = $rcFeeds;
}
$performer = $this->getPerformerIdentity();
@@ -592,20 +595,19 @@ class RecentChange implements Taggable {
*/
public static function getEngine( $uri, $params = [] ) {
// TODO: Merge into RCFeed::factory().
- global $wgRCEngines;
+ $rcEngines = MediaWikiServices::getInstance()->getMainConfig()->get( 'RCEngines' );
$scheme = parse_url( $uri, PHP_URL_SCHEME );
if ( !$scheme ) {
throw new MWException( "Invalid RCFeed uri: '$uri'" );
}
- if ( !isset( $wgRCEngines[$scheme] ) ) {
+ if ( !isset( $rcEngines[$scheme] ) ) {
throw new MWException( "Unknown RCFeedEngine scheme: '$scheme'" );
}
- if ( defined( 'MW_PHPUNIT_TEST' ) && is_object( $wgRCEngines[$scheme] ) ) {
- return $wgRCEngines[$scheme];
+ if ( defined( 'MW_PHPUNIT_TEST' ) && is_object( $rcEngines[$scheme] ) ) {
+ return $rcEngines[$scheme];
}
// TODO For non test a object could be here?
- // @phan-suppress-next-line PhanTypeExpectedObjectOrClassName
- return new $wgRCEngines[$scheme]( $params );
+ return new $rcEngines[$scheme]( $params );
}
/**
@@ -620,8 +622,10 @@ class RecentChange implements Taggable {
* @return array[] Array of permissions errors, see PermissionManager::getPermissionErrors()
*/
public function doMarkPatrolled( Authority $performer, $auto = false, $tags = null ) {
- global $wgUseRCPatrol, $wgUseNPPatrol, $wgUseFilePatrol;
-
+ $mainConfig = MediaWikiServices::getInstance()->getMainConfig();
+ $useRCPatrol = $mainConfig->get( 'UseRCPatrol' );
+ $useNPPatrol = $mainConfig->get( 'UseNPPatrol' );
+ $useFilePatrol = $mainConfig->get( 'UseFilePatrol' );
// Fix up $tags so that the MarkPatrolled hook below always gets an array
if ( $tags === null ) {
$tags = [];
@@ -632,8 +636,8 @@ class RecentChange implements Taggable {
$status = PermissionStatus::newEmpty();
// If recentchanges patrol is disabled, only new pages or new file versions
// can be patrolled, provided the appropriate config variable is set
- if ( !$wgUseRCPatrol && ( !$wgUseNPPatrol || $this->getAttribute( 'rc_type' ) != RC_NEW ) &&
- ( !$wgUseFilePatrol || !( $this->getAttribute( 'rc_type' ) == RC_LOG &&
+ if ( !$useRCPatrol && ( !$useNPPatrol || $this->getAttribute( 'rc_type' ) != RC_NEW ) &&
+ ( !$useFilePatrol || !( $this->getAttribute( 'rc_type' ) == RC_LOG &&
$this->getAttribute( 'rc_log_type' ) == 'upload' ) ) ) {
$status->fatal( 'rcpatroldisabled' );
}
@@ -886,10 +890,10 @@ class RecentChange implements Taggable {
$logPage, $user, $actionComment, $ip, $type,
$action, $target, $logComment, $params, $newId = 0, $actionCommentIRC = ''
) {
- global $wgLogRestrictions;
+ $logRestrictions = MediaWikiServices::getInstance()->getMainConfig()->get( 'LogRestrictions' );
# Don't add private logs to RC!
- if ( isset( $wgLogRestrictions[$type] ) && $wgLogRestrictions[$type] != '*' ) {
+ if ( isset( $logRestrictions[$type] ) && $logRestrictions[$type] != '*' ) {
return false;
}
$rc = self::newLogEntry( $timestamp,
@@ -1271,9 +1275,9 @@ class RecentChange implements Taggable {
* @return bool
*/
public static function isInRCLifespan( $timestamp, $tolerance = 0 ) {
- global $wgRCMaxAge;
+ $rcMaxAge = MediaWikiServices::getInstance()->getMainConfig()->get( 'RCMaxAge' );
- return wfTimestamp( TS_UNIX, $timestamp ) > time() - $tolerance - $wgRCMaxAge;
+ return wfTimestamp( TS_UNIX, $timestamp ) > time() - $tolerance - $rcMaxAge;
}
/**
diff --git a/includes/changetags/ChangeTags.php b/includes/changetags/ChangeTags.php
index 9aeff5db5ca8..011ae70f5443 100644
--- a/includes/changetags/ChangeTags.php
+++ b/includes/changetags/ChangeTags.php
@@ -156,18 +156,18 @@ class ChangeTags {
* @return array Array of all defined/enabled tags.
*/
public static function getSoftwareTags( $all = false ) {
- global $wgSoftwareTags;
+ $coreTags = MediaWikiServices::getInstance()->getMainConfig()->get( 'SoftwareTags' );
$softwareTags = [];
- if ( !is_array( $wgSoftwareTags ) ) {
+ if ( !is_array( $coreTags ) ) {
wfWarn( 'wgSoftwareTags should be associative array of enabled tags.
Please refer to documentation for the list of tags you can enable' );
return $softwareTags;
}
$availableSoftwareTags = !$all ?
- array_keys( array_filter( $wgSoftwareTags ) ) :
- array_keys( $wgSoftwareTags );
+ array_keys( array_filter( $coreTags ) ) :
+ array_keys( $coreTags );
$softwareTags = array_intersect(
$availableSoftwareTags,
@@ -896,7 +896,7 @@ class ChangeTags {
public static function modifyDisplayQuery( &$tables, &$fields, &$conds,
&$join_conds, &$options, $filter_tag = ''
) {
- global $wgUseTagFilter;
+ $useTagFilter = MediaWikiServices::getInstance()->getMainConfig()->get( 'UseTagFilter' );
// Normalize to arrays
$tables = (array)$tables;
@@ -919,7 +919,7 @@ class ChangeTags {
throw new MWException( 'Unable to determine appropriate JOIN condition for tagging.' );
}
- if ( $wgUseTagFilter && $filter_tag ) {
+ if ( $useTagFilter && $filter_tag ) {
// Somebody wants to filter on a tag.
// Add an INNER JOIN on change_tag
$tagTable = self::getDisplayTableName();
diff --git a/includes/collation/Collation.php b/includes/collation/Collation.php
index 939eb243f005..943940fb470e 100644
--- a/includes/collation/Collation.php
+++ b/includes/collation/Collation.php
@@ -38,8 +38,8 @@ abstract class Collation {
public static function singleton() {
wfDeprecated( __METHOD__, '1.37' );
if ( !self::$instance ) {
- global $wgCategoryCollation;
- self::$instance = self::factory( $wgCategoryCollation );
+ $categoryCollation = MediaWikiServices::getInstance()->getMainConfig()->get( 'CategoryCollation' );
+ self::$instance = self::factory( $categoryCollation );
}
return self::$instance;
}
diff --git a/includes/config/ConfigFactory.php b/includes/config/ConfigFactory.php
index bd174b2ed675..49eccda47848 100644
--- a/includes/config/ConfigFactory.php
+++ b/includes/config/ConfigFactory.php
@@ -20,6 +20,8 @@
*
* @file
*/
+
+use MediaWiki\MediaWikiServices;
use Wikimedia\Assert\Assert;
use Wikimedia\Services\SalvageableService;
@@ -49,7 +51,7 @@ class ConfigFactory implements SalvageableService {
* @return ConfigFactory
*/
public static function getDefaultInstance() {
- return \MediaWiki\MediaWikiServices::getInstance()->getConfigFactory();
+ return MediaWikiServices::getInstance()->getConfigFactory();
}
/**
diff --git a/includes/content/AbstractContent.php b/includes/content/AbstractContent.php
index f0a76e3b8c18..68ce351ce2a0 100644
--- a/includes/content/AbstractContent.php
+++ b/includes/content/AbstractContent.php
@@ -276,14 +276,14 @@ abstract class AbstractContent implements Content {
* @see Content::getRedirectChain
*/
public function getRedirectChain() {
- global $wgMaxRedirects;
+ $maxRedirects = MediaWikiServices::getInstance()->getMainConfig()->get( 'MaxRedirects' );
$title = $this->getRedirectTarget();
if ( $title === null ) {
return null;
}
$wikiPageFactory = MediaWikiServices::getInstance()->getWikiPageFactory();
// recursive check to follow double redirects
- $recurse = $wgMaxRedirects;
+ $recurse = $maxRedirects;
$titles = [ $title ];
while ( --$recurse > 0 ) {
if ( $title->isRedirect() ) {
diff --git a/includes/content/ContentHandler.php b/includes/content/ContentHandler.php
index 1a77121b45d1..100d66171e6f 100644
--- a/includes/content/ContentHandler.php
+++ b/includes/content/ContentHandler.php
@@ -95,7 +95,8 @@ abstract class ContentHandler {
* @return string|null Textual form of the content, if available.
*/
public static function getContentText( Content $content = null ) {
- global $wgContentHandlerTextFallback;
+ $contentHandlerTextFallback = MediaWikiServices::getInstance()
+ ->getMainConfig()->get( 'ContentHandlerTextFallback' );
if ( $content === null ) {
return '';
@@ -107,14 +108,14 @@ abstract class ContentHandler {
wfDebugLog( 'ContentHandler', 'Accessing ' . $content->getModel() . ' content as text!' );
- if ( $wgContentHandlerTextFallback == 'fail' ) {
+ if ( $contentHandlerTextFallback == 'fail' ) {
throw new MWException(
"Attempt to get text from Content with model " .
$content->getModel()
);
}
- if ( $wgContentHandlerTextFallback == 'serialize' ) {
+ if ( $contentHandlerTextFallback == 'serialize' ) {
return $content->serialize();
}
diff --git a/includes/content/CssContentHandler.php b/includes/content/CssContentHandler.php
index 49f3bf4cced8..cd9d83e63c22 100644
--- a/includes/content/CssContentHandler.php
+++ b/includes/content/CssContentHandler.php
@@ -109,9 +109,9 @@ class CssContentHandler extends CodeContentHandler {
ContentParseParams $cpoParams,
ParserOutput &$output
) {
- global $wgTextModelsToParse;
+ $textModelsToParse = MediaWikiServices::getInstance()->getMainConfig()->get( 'TextModelsToParse' );
'@phan-var CssContent $content';
- if ( in_array( $content->getModel(), $wgTextModelsToParse ) ) {
+ if ( in_array( $content->getModel(), $textModelsToParse ) ) {
// parse just to get links etc into the database, HTML is replaced below.
$output = MediaWikiServices::getInstance()->getParser()
->parse(
diff --git a/includes/content/JavaScriptContentHandler.php b/includes/content/JavaScriptContentHandler.php
index 3482439f55de..8c6f9102040f 100644
--- a/includes/content/JavaScriptContentHandler.php
+++ b/includes/content/JavaScriptContentHandler.php
@@ -124,9 +124,9 @@ class JavaScriptContentHandler extends CodeContentHandler {
ContentParseParams $cpoParams,
ParserOutput &$output
) {
- global $wgTextModelsToParse;
+ $textModelsToParse = MediaWikiServices::getInstance()->getMainConfig()->get( 'TextModelsToParse' );
'@phan-var TextContent $content';
- if ( in_array( $content->getModel(), $wgTextModelsToParse ) ) {
+ if ( in_array( $content->getModel(), $textModelsToParse ) ) {
// parse just to get links etc into the database, HTML is replaced below.
$output = MediaWikiServices::getInstance()->getParser()
->parse(
diff --git a/includes/content/TextContent.php b/includes/content/TextContent.php
index 9c3f61aff8fe..a8e9e437d41b 100644
--- a/includes/content/TextContent.php
+++ b/includes/content/TextContent.php
@@ -116,13 +116,13 @@ class TextContent extends AbstractContent {
* @return bool
*/
public function isCountable( $hasLinks = null ) {
- global $wgArticleCountMethod;
+ $articleCountMethod = MediaWikiServices::getInstance()->getMainConfig()->get( 'ArticleCountMethod' );
if ( $this->isRedirect() ) {
return false;
}
- if ( $wgArticleCountMethod === 'any' ) {
+ if ( $articleCountMethod === 'any' ) {
return true;
}
diff --git a/includes/content/TextContentHandler.php b/includes/content/TextContentHandler.php
index ca980ecc3857..d52406e5432f 100644
--- a/includes/content/TextContentHandler.php
+++ b/includes/content/TextContentHandler.php
@@ -213,9 +213,9 @@ class TextContentHandler extends ContentHandler {
ContentParseParams $cpoParams,
ParserOutput &$output
) {
- global $wgTextModelsToParse;
+ $textModelsToParse = MediaWikiServices::getInstance()->getMainConfig()->get( 'TextModelsToParse' );
'@phan-var TextContent $content';
- if ( in_array( $content->getModel(), $wgTextModelsToParse ) ) {
+ if ( in_array( $content->getModel(), $textModelsToParse ) ) {
// parse just to get links etc into the database, HTML is replaced below.
$output = MediaWikiServices::getInstance()->getParser()
->parse(
diff --git a/includes/content/WikitextContent.php b/includes/content/WikitextContent.php
index b1d65ce99d94..bc9f217fa220 100644
--- a/includes/content/WikitextContent.php
+++ b/includes/content/WikitextContent.php
@@ -145,13 +145,13 @@ class WikitextContent extends TextContent {
* @return array List of two elements: Title|null and string.
*/
public function getRedirectTargetAndText() {
- global $wgMaxRedirects;
+ $maxRedirects = MediaWikiServices::getInstance()->getMainConfig()->get( 'MaxRedirects' );
if ( $this->redirectTargetAndText !== null ) {
return $this->redirectTargetAndText;
}
- if ( $wgMaxRedirects < 1 ) {
+ if ( $maxRedirects < 1 ) {
// redirects are disabled, so quit early
$this->redirectTargetAndText = [ null, $this->getText() ];
return $this->redirectTargetAndText;
@@ -239,13 +239,13 @@ class WikitextContent extends TextContent {
* @return bool
*/
public function isCountable( $hasLinks = null, Title $title = null ) {
- global $wgArticleCountMethod;
+ $articleCountMethod = MediaWikiServices::getInstance()->getMainConfig()->get( 'ArticleCountMethod' );
if ( $this->isRedirect() ) {
return false;
}
- if ( $wgArticleCountMethod === 'link' ) {
+ if ( $articleCountMethod === 'link' ) {
if ( $hasLinks === null ) { # not known, find out
// @TODO: require an injected title
if ( !$title ) {
diff --git a/includes/db/MWLBFactory.php b/includes/db/MWLBFactory.php
index 2cf1937bd028..49bb0c5a961c 100644
--- a/includes/db/MWLBFactory.php
+++ b/includes/db/MWLBFactory.php
@@ -23,6 +23,7 @@
use MediaWiki\Config\ServiceOptions;
use MediaWiki\Logger\LoggerFactory;
+use MediaWiki\MediaWikiServices;
use Wikimedia\Rdbms\ChronologyProtector;
use Wikimedia\Rdbms\DatabaseDomain;
use Wikimedia\Rdbms\IDatabase;
@@ -87,7 +88,7 @@ abstract class MWLBFactory {
) {
$options->assertRequiredOptions( self::APPLY_DEFAULT_CONFIG_OPTIONS );
- global $wgCommandLineMode;
+ $commandLineMode = MediaWikiServices::getInstance()->getMainConfig()->get( 'CommandLineMode' );
$typesWithSchema = self::getDbTypesWithSchemas();
@@ -107,7 +108,7 @@ abstract class MWLBFactory {
'perfLogger' => LoggerFactory::getInstance( 'DBPerformance' ),
'errorLogger' => [ MWExceptionHandler::class, 'logException' ],
'deprecationLogger' => [ static::class, 'logDeprecation' ],
- 'cliMode' => $wgCommandLineMode,
+ 'cliMode' => $commandLineMode,
'readOnlyReason' => $readOnlyMode->getReason(),
'defaultGroup' => $options->get( 'DBDefaultGroup' ),
'criticalSectionProvider' => $csProvider
diff --git a/includes/deferred/CdnCacheUpdate.php b/includes/deferred/CdnCacheUpdate.php
index 893f99418e5e..ae21c7e00b7a 100644
--- a/includes/deferred/CdnCacheUpdate.php
+++ b/includes/deferred/CdnCacheUpdate.php
@@ -113,8 +113,8 @@ class CdnCacheUpdate implements DeferrableUpdate, MergeableUpdate {
* @param string[] $urls List of full URLs to purge
*/
public static function purge( array $urls ) {
- global $wgCdnServers, $wgHTCPRouting;
-
+ $cdnServers = MediaWikiServices::getInstance()->getMainConfig()->get( 'CdnServers' );
+ $htcpRouting = MediaWikiServices::getInstance()->getMainConfig()->get( 'HTCPRouting' );
if ( !$urls ) {
return;
}
@@ -141,12 +141,12 @@ class CdnCacheUpdate implements DeferrableUpdate, MergeableUpdate {
);
// Send lossy UDP broadcasting if enabled
- if ( $wgHTCPRouting ) {
+ if ( $htcpRouting ) {
self::HTCPPurge( $urls );
}
// Do direct server purges if enabled (this does not scale very well)
- if ( $wgCdnServers ) {
+ if ( $cdnServers ) {
self::naivePurge( $urls );
}
}
@@ -198,8 +198,8 @@ class CdnCacheUpdate implements DeferrableUpdate, MergeableUpdate {
* @param string[] $urls Collection of URLs to purge
*/
private static function HTCPPurge( array $urls ) {
- global $wgHTCPRouting, $wgHTCPMulticastTTL;
-
+ $htcpRouting = MediaWikiServices::getInstance()->getMainConfig()->get( 'HTCPRouting' );
+ $htcpMulticastTTL = MediaWikiServices::getInstance()->getMainConfig()->get( 'HTCPMulticastTTL' );
// HTCP CLR operation
$htcpOpCLR = 4;
@@ -222,10 +222,10 @@ class CdnCacheUpdate implements DeferrableUpdate, MergeableUpdate {
// Set socket options
socket_set_option( $conn, IPPROTO_IP, IP_MULTICAST_LOOP, 0 );
- if ( $wgHTCPMulticastTTL != 1 ) {
+ if ( $htcpMulticastTTL != 1 ) {
// Set multicast time to live (hop count) option on socket
socket_set_option( $conn, IPPROTO_IP, IP_MULTICAST_TTL,
- $wgHTCPMulticastTTL );
+ $htcpMulticastTTL );
}
// Get sequential trx IDs for packet loss counting
@@ -241,7 +241,7 @@ class CdnCacheUpdate implements DeferrableUpdate, MergeableUpdate {
throw new MWException( 'Bad purge URL' );
}
$url = self::expand( $url );
- $conf = self::getRuleForURL( $url, $wgHTCPRouting );
+ $conf = self::getRuleForURL( $url, $htcpRouting );
if ( !$conf ) {
wfDebugLog( 'squid', __METHOD__ .
"No HTCP rule configured for URL {$url} , skipping" );
@@ -294,7 +294,7 @@ class CdnCacheUpdate implements DeferrableUpdate, MergeableUpdate {
* @throws Exception
*/
private static function naivePurge( array $urls ) {
- global $wgCdnServers;
+ $cdnServers = MediaWikiServices::getInstance()->getMainConfig()->get( 'CdnServers' );
$reqs = [];
foreach ( $urls as $url ) {
@@ -313,7 +313,7 @@ class CdnCacheUpdate implements DeferrableUpdate, MergeableUpdate {
'User-Agent' => 'MediaWiki/' . MW_VERSION . ' ' . __CLASS__
]
];
- foreach ( $wgCdnServers as $server ) {
+ foreach ( $cdnServers as $server ) {
$reqs[] = ( $baseReq + [ 'proxy' => $server ] );
}
}
diff --git a/includes/deferred/DeferredUpdates.php b/includes/deferred/DeferredUpdates.php
index b5e5f6e2952e..384887660903 100644
--- a/includes/deferred/DeferredUpdates.php
+++ b/includes/deferred/DeferredUpdates.php
@@ -117,7 +117,7 @@ class DeferredUpdates {
* @since 1.28 Added the $stage parameter
*/
public static function addUpdate( DeferrableUpdate $update, $stage = self::POSTSEND ) {
- global $wgCommandLineMode;
+ $commandLineMode = MediaWikiServices::getInstance()->getMainConfig()->get( 'CommandLineMode' );
self::getScopeStack()->current()->addUpdate( $update, $stage );
// If CLI mode is active and no RDBMs transaction round is in the way, then run all
@@ -125,7 +125,7 @@ class DeferredUpdates {
// RDBMs layer, but that do modify systems via deferred updates. This logic avoids
// excessive pending update queue sizes when long-running scripts never trigger the
// basic RDBMs hooks for running pending updates.
- if ( $wgCommandLineMode ) {
+ if ( $commandLineMode ) {
self::tryOpportunisticExecute( 'run' );
}
}
diff --git a/includes/exception/MWException.php b/includes/exception/MWException.php
index 47bbaf9f1ff8..d9f3a1cdd697 100644
--- a/includes/exception/MWException.php
+++ b/includes/exception/MWException.php
@@ -1,4 +1,5 @@
<?php
+
/**
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -18,6 +19,8 @@
* @file
*/
+use MediaWiki\MediaWikiServices;
+
/**
* MediaWiki exception
*
@@ -79,7 +82,7 @@ class MWException extends Exception {
* @return string Message with arguments replaced
*/
public function msg( $key, $fallback, ...$params ) {
- global $wgSitename;
+ $sitename = MediaWikiServices::getInstance()->getMainConfig()->get( 'Sitename' );
// FIXME: Keep logic in sync with MWExceptionRenderer::msg.
$res = false;
@@ -94,7 +97,7 @@ class MWException extends Exception {
// If an exception happens inside message rendering,
// {{SITENAME}} sometimes won't be replaced.
$res = strtr( $res, [
- '{{SITENAME}}' => $wgSitename,
+ '{{SITENAME}}' => $sitename,
] );
}
return $res;
@@ -110,9 +113,9 @@ class MWException extends Exception {
* @return string Html to output
*/
public function getHTML() {
- global $wgShowExceptionDetails;
+ $showExceptionDetails = MediaWikiServices::getInstance()->getMainConfig()->get( 'ShowExceptionDetails' );
- if ( $wgShowExceptionDetails ) {
+ if ( $showExceptionDetails ) {
return '<p>' . nl2br( htmlspecialchars( MWExceptionHandler::getLogMessage( $this ) ) ) .
'</p><p>Backtrace:</p><p>' .
nl2br( htmlspecialchars( MWExceptionHandler::getRedactedTraceAsString( $this ) ) ) .
@@ -147,9 +150,9 @@ class MWException extends Exception {
* @return string
*/
public function getText() {
- global $wgShowExceptionDetails;
+ $showExceptionDetails = MediaWikiServices::getInstance()->getMainConfig()->get( 'ShowExceptionDetails' );
- if ( $wgShowExceptionDetails ) {
+ if ( $showExceptionDetails ) {
return MWExceptionHandler::getLogMessage( $this ) .
"\nBacktrace:\n" . MWExceptionHandler::getRedactedTraceAsString( $this ) . "\n";
} else {
@@ -174,7 +177,8 @@ class MWException extends Exception {
* @stable to override
*/
public function reportHTML() {
- global $wgOut, $wgSitename;
+ global $wgOut;
+ $sitename = MediaWikiServices::getInstance()->getMainConfig()->get( 'Sitename' );
if ( $this->useOutputPage() ) {
$wgOut->prepareErrorPage( $this->getPageTitle() );
// Manually set the html title, since sometimes
@@ -183,7 +187,7 @@ class MWException extends Exception {
$wgOut->setHTMLTitle(
$this->msg(
'pagetitle',
- "$1 - $wgSitename",
+ "$1 - {$sitename}",
$this->getPageTitle()
)
);
@@ -197,7 +201,7 @@ class MWException extends Exception {
'<html><head>' .
// Mimic OutputPage::setPageTitle behaviour
'<title>' .
- htmlspecialchars( $this->msg( 'pagetitle', "$1 - $wgSitename", $this->getPageTitle() ) ) .
+ htmlspecialchars( $this->msg( 'pagetitle', "$1 - {$sitename}", $this->getPageTitle() ) ) .
'</title>' .
'<style>body { font-family: sans-serif; margin: 0; padding: 0.5em 2em; }</style>' .
"</head><body>\n";
@@ -215,7 +219,7 @@ class MWException extends Exception {
* @stable to override
*/
public function report() {
- global $wgMimeType;
+ $mimeType = MediaWikiServices::getInstance()->getMainConfig()->get( 'MimeType' );
if ( defined( 'MW_API' ) ) {
self::header( 'MediaWiki-API-Error: internal_api_error_' . static::class );
@@ -226,7 +230,7 @@ class MWException extends Exception {
$this->writeToCommandLine( $message );
} else {
self::statusHeader( 500 );
- self::header( "Content-Type: $wgMimeType; charset=utf-8" );
+ self::header( "Content-Type: {$mimeType}; charset=utf-8" );
$this->reportHTML();
}
diff --git a/includes/exception/MWExceptionRenderer.php b/includes/exception/MWExceptionRenderer.php
index b4dc49d883ea..a7ed8284e064 100644
--- a/includes/exception/MWExceptionRenderer.php
+++ b/includes/exception/MWExceptionRenderer.php
@@ -39,8 +39,8 @@ class MWExceptionRenderer {
* @param Throwable|null $eNew New throwable from attempting to show the first
*/
public static function output( Throwable $e, $mode, Throwable $eNew = null ) {
- global $wgMimeType, $wgShowExceptionDetails;
-
+ $mimeType = MediaWikiServices::getInstance()->getMainConfig()->get( 'MimeType' );
+ $showExceptionDetails = MediaWikiServices::getInstance()->getMainConfig()->get( 'ShowExceptionDetails' );
if ( $e instanceof RequestTimeoutException && headers_sent() ) {
// Excimer's flag check happens on function return, so, a timeout
// can be thrown after exiting, say, `doPostOutputShutdown`, where
@@ -69,7 +69,7 @@ class MWExceptionRenderer {
self::printError( self::getText( $e ) );
} elseif ( $mode === self::AS_PRETTY ) {
self::statusHeader( 500 );
- self::header( "Content-Type: $wgMimeType; charset=UTF-8" );
+ self::header( "Content-Type: {$mimeType}; charset=UTF-8" );
ob_start();
if ( $e instanceof DBConnectionError ) {
self::reportOutageHTML( $e );
@@ -81,10 +81,10 @@ class MWExceptionRenderer {
} else {
ob_start();
self::statusHeader( 500 );
- self::header( "Content-Type: $wgMimeType; charset=UTF-8" );
+ self::header( "Content-Type: {$mimeType}; charset=UTF-8" );
if ( $eNew ) {
$message = "MediaWiki internal error.\n\n";
- if ( $wgShowExceptionDetails ) {
+ if ( $showExceptionDetails ) {
$message .= 'Original exception: ' .
MWExceptionHandler::getLogMessage( $e ) .
"\nBacktrace:\n" . MWExceptionHandler::getRedactedTraceAsString( $e ) .
@@ -98,7 +98,7 @@ class MWExceptionRenderer {
self::getShowBacktraceError( $e );
}
$message .= "\n";
- } elseif ( $wgShowExceptionDetails ) {
+ } elseif ( $showExceptionDetails ) {
$message = MWExceptionHandler::getLogMessage( $e ) .
"\nBacktrace:\n" .
MWExceptionHandler::getRedactedTraceAsString( $e ) . "\n";
@@ -143,8 +143,8 @@ class MWExceptionRenderer {
* @param Throwable $e
*/
private static function reportHTML( Throwable $e ) {
- global $wgOut, $wgSitename;
-
+ global $wgOut;
+ $sitename = MediaWikiServices::getInstance()->getMainConfig()->get( 'Sitename' );
if ( self::useOutputPage( $e ) ) {
$wgOut->prepareErrorPage( self::getExceptionTitle( $e ) );
@@ -163,7 +163,7 @@ class MWExceptionRenderer {
'<html><head>' .
// Mimic OutputPage::setPageTitle behaviour
'<title>' .
- htmlspecialchars( self::msg( 'pagetitle', "$1 - $wgSitename", $pageTitle ) ) .
+ htmlspecialchars( self::msg( 'pagetitle', "$1 - {$sitename}", $pageTitle ) ) .
'</title>' .
'<style>body { font-family: sans-serif; margin: 0; padding: 0.5em 2em; }</style>' .
"</head><body>\n";
@@ -183,9 +183,9 @@ class MWExceptionRenderer {
* @return string Html to output
*/
public static function getHTML( Throwable $e ) {
- global $wgShowExceptionDetails;
+ $showExceptionDetails = MediaWikiServices::getInstance()->getMainConfig()->get( 'ShowExceptionDetails' );
- if ( $wgShowExceptionDetails ) {
+ if ( $showExceptionDetails ) {
$html = "<div class=\"errorbox mw-content-ltr\"><p>" .
nl2br( htmlspecialchars( MWExceptionHandler::getLogMessage( $e ) ) ) .
'</p><p>Backtrace:</p><p>' .
@@ -219,7 +219,7 @@ class MWExceptionRenderer {
* @return string Message with arguments replaced
*/
private static function msg( $key, $fallback, ...$params ) {
- global $wgSitename;
+ $sitename = MediaWikiServices::getInstance()->getMainConfig()->get( 'Sitename' );
// FIXME: Keep logic in sync with MWException::msg.
try {
@@ -229,7 +229,7 @@ class MWExceptionRenderer {
// If an exception happens inside message rendering,
// {{SITENAME}} sometimes won't be replaced.
$res = strtr( $res, [
- '{{SITENAME}}' => $wgSitename,
+ '{{SITENAME}}' => $sitename,
] );
}
return $res;
@@ -240,9 +240,9 @@ class MWExceptionRenderer {
* @return string
*/
private static function getText( Throwable $e ) {
- global $wgShowExceptionDetails;
+ $showExceptionDetails = MediaWikiServices::getInstance()->getMainConfig()->get( 'ShowExceptionDetails' );
- if ( $wgShowExceptionDetails ) {
+ if ( $showExceptionDetails ) {
return MWExceptionHandler::getLogMessage( $e ) .
"\nBacktrace:\n" .
MWExceptionHandler::getRedactedTraceAsString( $e ) . "\n";
@@ -350,8 +350,10 @@ class MWExceptionRenderer {
* @param Throwable $e
*/
private static function reportOutageHTML( Throwable $e ) {
- global $wgShowExceptionDetails, $wgShowHostnames, $wgSitename;
-
+ $mainConfig = MediaWikiServices::getInstance()->getMainConfig();
+ $showExceptionDetails = $mainConfig->get( 'ShowExceptionDetails' );
+ $showHostnames = $mainConfig->get( 'ShowHostnames' );
+ $sitename = $mainConfig->get( 'Sitename' );
$sorry = htmlspecialchars( self::msg(
'dberr-problems',
'Sorry! This site is experiencing technical difficulties.'
@@ -361,7 +363,7 @@ class MWExceptionRenderer {
'Try waiting a few minutes and reloading.'
) );
- if ( $wgShowHostnames ) {
+ if ( $showHostnames ) {
$info = str_replace(
'$1',
Html::element( 'span', [ 'dir' => 'ltr' ], $e->getMessage() ),
@@ -378,12 +380,12 @@ class MWExceptionRenderer {
$html = "<!DOCTYPE html>\n" .
'<html><head>' .
'<title>' .
- htmlspecialchars( $wgSitename ) .
+ htmlspecialchars( $sitename ) .
'</title>' .
'<style>body { font-family: sans-serif; margin: 0; padding: 0.5em 2em; }</style>' .
"</head><body><h1>$sorry</h1><p>$again</p><p><small>$info</small></p>";
- if ( $wgShowExceptionDetails ) {
+ if ( $showExceptionDetails ) {
$html .= '<p>Backtrace:</p><pre>' .
htmlspecialchars( $e->getTraceAsString() ) . '</pre>';
}
diff --git a/includes/export/WikiExporter.php b/includes/export/WikiExporter.php
index a54df7498e35..0813a3e15096 100644
--- a/includes/export/WikiExporter.php
+++ b/includes/export/WikiExporter.php
@@ -29,6 +29,7 @@
use MediaWiki\HookContainer\HookContainer;
use MediaWiki\HookContainer\HookRunner;
+use MediaWiki\MediaWikiServices;
use MediaWiki\Page\PageIdentity;
use MediaWiki\Revision\RevisionAccessException;
use MediaWiki\Revision\RevisionRecord;
@@ -95,8 +96,8 @@ class WikiExporter {
* @return string
*/
public static function schemaVersion() {
- global $wgXmlDumpSchemaVersion;
- return $wgXmlDumpSchemaVersion;
+ $xmlDumpSchemaVersion = MediaWikiServices::getInstance()->getMainConfig()->get( 'XmlDumpSchemaVersion' );
+ return $xmlDumpSchemaVersion;
}
/**
diff --git a/includes/export/XmlDumpWriter.php b/includes/export/XmlDumpWriter.php
index c36c48187183..8f70f045da31 100644
--- a/includes/export/XmlDumpWriter.php
+++ b/includes/export/XmlDumpWriter.php
@@ -163,16 +163,16 @@ class XmlDumpWriter {
* @return string
*/
private function sitename() {
- global $wgSitename;
- return Xml::element( 'sitename', [], $wgSitename );
+ $sitename = MediaWikiServices::getInstance()->getMainConfig()->get( 'Sitename' );
+ return Xml::element( 'sitename', [], $sitename );
}
/**
* @return string
*/
private function dbname() {
- global $wgDBname;
- return Xml::element( 'dbname', [], $wgDBname );
+ $dbname = MediaWikiServices::getInstance()->getMainConfig()->get( 'DBname' );
+ return Xml::element( 'dbname', [], $dbname );
}
/**
@@ -193,9 +193,9 @@ class XmlDumpWriter {
* @return string
*/
private function caseSetting() {
- global $wgCapitalLinks;
+ $capitalLinks = MediaWikiServices::getInstance()->getMainConfig()->get( 'CapitalLinks' );
// "case-insensitive" option is reserved for future
- $sensitivity = $wgCapitalLinks ? 'first-letter' : 'case-sensitive';
+ $sensitivity = $capitalLinks ? 'first-letter' : 'case-sensitive';
return Xml::element( 'case', [], $sensitivity );
}
diff --git a/includes/filerepo/FileRepo.php b/includes/filerepo/FileRepo.php
index 813bb38ce609..66fa2433bf18 100644
--- a/includes/filerepo/FileRepo.php
+++ b/includes/filerepo/FileRepo.php
@@ -1618,7 +1618,7 @@ class FileRepo {
*/
public function getFileProps( $virtualUrl ) {
$fsFile = $this->getLocalReference( $virtualUrl );
- $mwProps = new MWFileProps( MediaWiki\MediaWikiServices::getInstance()->getMimeAnalyzer() );
+ $mwProps = new MWFileProps( MediaWikiServices::getInstance()->getMimeAnalyzer() );
if ( $fsFile ) {
$props = $mwProps->getPropsFromPath( $fsFile->getPath(), true );
} else {
@@ -1839,10 +1839,10 @@ class FileRepo {
* @return string
*/
public function getDisplayName() {
- global $wgSitename;
+ $sitename = MediaWikiServices::getInstance()->getMainConfig()->get( 'Sitename' );
if ( $this->isLocal() ) {
- return $wgSitename;
+ return $sitename;
}
// 'shared-repo-name-wikimediacommons' is used when $wgUseInstantCommons = true
diff --git a/includes/filerepo/ForeignAPIRepo.php b/includes/filerepo/ForeignAPIRepo.php
index a8ccea418f61..61130f7c0b43 100644
--- a/includes/filerepo/ForeignAPIRepo.php
+++ b/includes/filerepo/ForeignAPIRepo.php
@@ -83,7 +83,7 @@ class ForeignAPIRepo extends FileRepo {
* @param array|null $info
*/
public function __construct( $info ) {
- global $wgLocalFileRepo;
+ $localFileRepo = MediaWikiServices::getInstance()->getMainConfig()->get( 'LocalFileRepo' );
parent::__construct( $info );
// https://commons.wikimedia.org/w/api.php
@@ -104,7 +104,7 @@ class ForeignAPIRepo extends FileRepo {
}
// If we can cache thumbs we can guess sensible defaults for these
if ( $this->canCacheThumbs() && !$this->url ) {
- $this->url = $wgLocalFileRepo['url'];
+ $this->url = $localFileRepo['url'];
}
if ( $this->canCacheThumbs() && !$this->thumbUrl ) {
$this->thumbUrl = $this->url . '/thumb';
@@ -202,7 +202,7 @@ class ForeignAPIRepo extends FileRepo {
* @return array|null
*/
public function fetchImageQuery( $query ) {
- global $wgLanguageCode;
+ $languageCode = MediaWikiServices::getInstance()->getMainConfig()->get( 'LanguageCode' );
$query = array_merge( $query,
[
@@ -212,7 +212,7 @@ class ForeignAPIRepo extends FileRepo {
] );
if ( !isset( $query['uselang'] ) ) { // uselang is unset or null
- $query['uselang'] = $wgLanguageCode;
+ $query['uselang'] = $languageCode;
}
$data = $this->httpGetCached( 'Metadata', $query, $this->apiMetadataExpiry );
diff --git a/includes/filerepo/LocalRepo.php b/includes/filerepo/LocalRepo.php
index 59c08c1fd6f5..1d9f8dd2984e 100644
--- a/includes/filerepo/LocalRepo.php
+++ b/includes/filerepo/LocalRepo.php
@@ -592,10 +592,10 @@ class LocalRepo extends FileRepo {
* @since 1.22
*/
public function getInfo() {
- global $wgFavicon;
+ $favicon = MediaWikiServices::getInstance()->getMainConfig()->get( 'Favicon' );
return array_merge( parent::getInfo(), [
- 'favicon' => wfExpandUrl( $wgFavicon ),
+ 'favicon' => wfExpandUrl( $favicon ),
] );
}
diff --git a/includes/filerepo/file/File.php b/includes/filerepo/file/File.php
index efc220b783de..0b8af11e6a91 100644
--- a/includes/filerepo/file/File.php
+++ b/includes/filerepo/file/File.php
@@ -281,7 +281,7 @@ abstract class File implements IDBAccessObject, MediaHandlerState {
$oldMime = $old->getMimeType();
$n = strrpos( $new, '.' );
$newExt = self::normalizeExtension( $n ? substr( $new, $n + 1 ) : '' );
- $mimeMagic = MediaWiki\MediaWikiServices::getInstance()->getMimeAnalyzer();
+ $mimeMagic = MediaWikiServices::getInstance()->getMimeAnalyzer();
return $mimeMagic->isMatchingExtension( $newExt, $oldMime );
}
@@ -530,8 +530,10 @@ abstract class File implements IDBAccessObject, MediaHandlerState {
* @return bool|int
*/
public function getThumbnailBucket( $desiredWidth, $page = 1 ) {
- global $wgThumbnailBuckets, $wgThumbnailMinimumBucketDistance;
-
+ $thumbnailBuckets = MediaWikiServices::getInstance()
+ ->getMainConfig()->get( 'ThumbnailBuckets' );
+ $thumbnailMinimumBucketDistance = MediaWikiServices::getInstance()
+ ->getMainConfig()->get( 'ThumbnailMinimumBucketDistance' );
$imageWidth = $this->getWidth( $page );
if ( $imageWidth === false ) {
@@ -542,11 +544,11 @@ abstract class File implements IDBAccessObject, MediaHandlerState {
return false;
}
- if ( !$wgThumbnailBuckets ) {
+ if ( !$thumbnailBuckets ) {
return false;
}
- $sortedBuckets = $wgThumbnailBuckets;
+ $sortedBuckets = $thumbnailBuckets;
sort( $sortedBuckets );
@@ -555,7 +557,7 @@ abstract class File implements IDBAccessObject, MediaHandlerState {
return false;
}
- if ( $bucket - $wgThumbnailMinimumBucketDistance > $desiredWidth ) {
+ if ( $bucket - $thumbnailMinimumBucketDistance > $desiredWidth ) {
return $bucket;
}
}
@@ -936,7 +938,7 @@ abstract class File implements IDBAccessObject, MediaHandlerState {
* @return bool
*/
protected function getIsSafeFileUncached() {
- global $wgTrustedMediaFormats;
+ $trustedMediaFormats = MediaWikiServices::getInstance()->getMainConfig()->get( 'TrustedMediaFormats' );
if ( $this->allowInlineDisplay() ) {
return true;
@@ -951,14 +953,14 @@ abstract class File implements IDBAccessObject, MediaHandlerState {
if ( !$type || $type === MEDIATYPE_UNKNOWN ) {
return false; # unknown type, not trusted
}
- if ( in_array( $type, $wgTrustedMediaFormats ) ) {
+ if ( in_array( $type, $trustedMediaFormats ) ) {
return true;
}
if ( $mime === "unknown/unknown" ) {
return false; # unknown type, not trusted
}
- if ( in_array( $mime, $wgTrustedMediaFormats ) ) {
+ if ( in_array( $mime, $trustedMediaFormats ) ) {
return true;
}
@@ -1146,10 +1148,10 @@ abstract class File implements IDBAccessObject, MediaHandlerState {
* @return MediaTransformOutput
*/
protected function transformErrorOutput( $thumbPath, $thumbUrl, $params, $flags ) {
- global $wgIgnoreImageErrors;
+ $ignoreImageErrors = MediaWikiServices::getInstance()->getMainConfig()->get( 'IgnoreImageErrors' );
$handler = $this->getHandler();
- if ( $handler && $wgIgnoreImageErrors && !( $flags & self::RENDER_NOW ) ) {
+ if ( $handler && $ignoreImageErrors && !( $flags & self::RENDER_NOW ) ) {
return $handler->getTransform( $this, $thumbPath, $thumbUrl, $params );
} else {
return new MediaTransformError( 'thumbnail_error',
@@ -1167,7 +1169,7 @@ abstract class File implements IDBAccessObject, MediaHandlerState {
* @return ThumbnailImage|MediaTransformOutput|bool False on failure
*/
public function transform( $params, $flags = 0 ) {
- global $wgThumbnailEpoch;
+ $thumbnailEpoch = MediaWikiServices::getInstance()->getMainConfig()->get( 'ThumbnailEpoch' );
do {
if ( !$this->canRender() ) {
@@ -1211,7 +1213,7 @@ abstract class File implements IDBAccessObject, MediaHandlerState {
wfDebug( __METHOD__ . ": Doing stat for $thumbPath" );
if ( !( $flags & self::RENDER_FORCE ) && $this->repo->fileExists( $thumbPath ) ) {
$timestamp = $this->repo->getFileTimestamp( $thumbPath );
- if ( $timestamp !== false && $timestamp >= $wgThumbnailEpoch ) {
+ if ( $timestamp !== false && $timestamp >= $thumbnailEpoch ) {
// XXX: Pass in the storage path even though we are not rendering anything
// and the path is supposed to be an FS path. This is due to getScalerType()
// getting called on the path and clobbering $thumb->getUrl() if it's false.
@@ -1264,7 +1266,7 @@ abstract class File implements IDBAccessObject, MediaHandlerState {
* @return bool|MediaTransformOutput
*/
public function generateAndSaveThumb( $tmpFile, $transformParams, $flags ) {
- global $wgIgnoreImageErrors;
+ $ignoreImageErrors = MediaWikiServices::getInstance()->getMainConfig()->get( 'IgnoreImageErrors' );
if ( !$this->repo->canTransformLocally() ) {
return new MediaTransformError(
@@ -1310,7 +1312,7 @@ abstract class File implements IDBAccessObject, MediaHandlerState {
'@phan-var MediaTransformError $thumb';
$this->lastError = $thumb->toText();
// Ignore errors if requested
- if ( $wgIgnoreImageErrors && !( $flags & self::RENDER_NOW ) ) {
+ if ( $ignoreImageErrors && !( $flags & self::RENDER_NOW ) ) {
$thumb = $handler->getTransform( $this, $tmpThumbPath, $thumbUrl, $transformParams );
}
} elseif ( $this->repo && $thumb->hasFile() && !$thumb->fileIsSource() ) {
@@ -1536,8 +1538,9 @@ abstract class File implements IDBAccessObject, MediaHandlerState {
* @return ThumbnailImage|null
*/
public function iconThumb() {
- global $wgResourceBasePath, $IP;
- $assetsPath = "$wgResourceBasePath/resources/assets/file-type-icons/";
+ global $IP;
+ $resourceBasePath = MediaWikiServices::getInstance()->getMainConfig()->get( 'ResourceBasePath' );
+ $assetsPath = "{$resourceBasePath}/resources/assets/file-type-icons/";
$assetsDirectory = "$IP/resources/assets/file-type-icons/";
$try = [ 'fileicon-' . $this->getExtension() . '.png', 'fileicon.png' ];
diff --git a/includes/filerepo/file/ForeignAPIFile.php b/includes/filerepo/file/ForeignAPIFile.php
index 34c8520f896e..bb4bb9322004 100644
--- a/includes/filerepo/file/ForeignAPIFile.php
+++ b/includes/filerepo/file/ForeignAPIFile.php
@@ -314,7 +314,7 @@ class ForeignAPIFile extends File {
*/
public function getMimeType() {
if ( !isset( $this->mInfo['mime'] ) ) {
- $magic = MediaWiki\MediaWikiServices::getInstance()->getMimeAnalyzer();
+ $magic = MediaWikiServices::getInstance()->getMimeAnalyzer();
$this->mInfo['mime'] = $magic->getMimeTypeFromExtensionOrNull( $this->getExtension() );
}
@@ -328,7 +328,7 @@ class ForeignAPIFile extends File {
if ( isset( $this->mInfo['mediatype'] ) ) {
return $this->mInfo['mediatype'];
}
- $magic = MediaWiki\MediaWikiServices::getInstance()->getMimeAnalyzer();
+ $magic = MediaWikiServices::getInstance()->getMimeAnalyzer();
return $magic->getMediaType( null, $this->getMimeType() );
}
diff --git a/includes/filerepo/file/LocalFile.php b/includes/filerepo/file/LocalFile.php
index 4dab0e0af3e7..388c26df3e2a 100644
--- a/includes/filerepo/file/LocalFile.php
+++ b/includes/filerepo/file/LocalFile.php
@@ -1527,11 +1527,12 @@ class LocalFile extends File {
* @since 1.28
*/
public function prerenderThumbnails() {
- global $wgUploadThumbnailRenderMap;
+ $uploadThumbnailRenderMap = MediaWikiServices::getInstance()
+ ->getMainConfig()->get( 'UploadThumbnailRenderMap' );
$jobs = [];
- $sizes = $wgUploadThumbnailRenderMap;
+ $sizes = $uploadThumbnailRenderMap;
rsort( $sizes );
foreach ( $sizes as $size ) {
diff --git a/includes/filerepo/file/MediaFileTrait.php b/includes/filerepo/file/MediaFileTrait.php
index fd064260edb3..5139c69e4696 100644
--- a/includes/filerepo/file/MediaFileTrait.php
+++ b/includes/filerepo/file/MediaFileTrait.php
@@ -147,21 +147,21 @@ trait MediaFileTrait {
* @since 1.35
*/
public static function getImageLimitsFromOption( UserIdentity $user, string $optionName ) {
- global $wgImageLimits;
+ $imageLimits = MediaWikiServices::getInstance()->getMainConfig()->get( 'ImageLimits' );
$optionsLookup = MediaWikiServices::getInstance()->getUserOptionsLookup();
$option = $optionsLookup->getIntOption( $user, $optionName );
- if ( !isset( $wgImageLimits[$option] ) ) {
+ if ( !isset( $imageLimits[$option] ) ) {
$option = $optionsLookup->getDefaultOption( $optionName );
}
// The user offset might still be incorrect, specially if
// $wgImageLimits got changed (see T10858).
- if ( !isset( $wgImageLimits[$option] ) ) {
+ if ( !isset( $imageLimits[$option] ) ) {
// Default to the first offset in $wgImageLimits
$option = 0;
}
// if nothing is set, fallback to a hardcoded default
- return $wgImageLimits[$option] ?? [ 800, 600 ];
+ return $imageLimits[$option] ?? [ 800, 600 ];
}
}
diff --git a/includes/filerepo/file/UnregisteredLocalFile.php b/includes/filerepo/file/UnregisteredLocalFile.php
index a34774d2bcac..2f677fe75329 100644
--- a/includes/filerepo/file/UnregisteredLocalFile.php
+++ b/includes/filerepo/file/UnregisteredLocalFile.php
@@ -1,4 +1,5 @@
<?php
+
/**
* File without associated database record.
*
@@ -21,6 +22,8 @@
* @ingroup FileAbstraction
*/
+use MediaWiki\MediaWikiServices;
+
/**
* A file object referring to either a standalone local file, or a file in a
* local repository with no database, for example an FileRepo repository.
@@ -159,7 +162,7 @@ class UnregisteredLocalFile extends File {
*/
public function getMimeType() {
if ( !isset( $this->mime ) ) {
- $magic = MediaWiki\MediaWikiServices::getInstance()->getMimeAnalyzer();
+ $magic = MediaWikiServices::getInstance()->getMimeAnalyzer();
$this->mime = $magic->guessMimeType( $this->getLocalRefPath() );
}
diff --git a/includes/htmlform/fields/HTMLCheckField.php b/includes/htmlform/fields/HTMLCheckField.php
index 9b524dc2a316..e4266b27eb69 100644
--- a/includes/htmlform/fields/HTMLCheckField.php
+++ b/includes/htmlform/fields/HTMLCheckField.php
@@ -1,5 +1,7 @@
<?php
+use MediaWiki\MediaWikiServices;
+
/**
* A checkbox field
*
@@ -12,7 +14,8 @@ class HTMLCheckField extends HTMLFormField {
* @stable to override
*/
public function getInputHTML( $value ) {
- global $wgUseMediaWikiUIEverywhere;
+ $useMediaWikiUIEverywhere = MediaWikiServices::getInstance()
+ ->getMainConfig()->get( 'UseMediaWikiUIEverywhere' );
if ( !empty( $this->mParams['invert'] ) ) {
$value = !$value;
@@ -37,7 +40,7 @@ class HTMLCheckField extends HTMLFormField {
"\u{00A0}" .
Html::rawElement( 'label', $attrLabel, $this->mLabel );
- if ( $wgUseMediaWikiUIEverywhere || $this->mParent instanceof VFormHTMLForm ) {
+ if ( $useMediaWikiUIEverywhere || $this->mParent instanceof VFormHTMLForm ) {
$chkLabel = Html::rawElement(
'div',
[ 'class' => 'mw-ui-checkbox' ],
diff --git a/includes/htmlform/fields/HTMLRadioField.php b/includes/htmlform/fields/HTMLRadioField.php
index ba6bade7d09f..a6cbaef7924d 100644
--- a/includes/htmlform/fields/HTMLRadioField.php
+++ b/includes/htmlform/fields/HTMLRadioField.php
@@ -1,5 +1,7 @@
<?php
+use MediaWiki\MediaWikiServices;
+
/**
* Radio checkbox fields.
*
@@ -77,7 +79,8 @@ class HTMLRadioField extends HTMLFormField {
}
public function formatOptions( $options, $value ) {
- global $wgUseMediaWikiUIEverywhere;
+ $useMediaWikiUIEverywhere = MediaWikiServices::getInstance()
+ ->getMainConfig()->get( 'UseMediaWikiUIEverywhere' );
$html = '';
@@ -92,7 +95,7 @@ class HTMLRadioField extends HTMLFormField {
} else {
$id = Sanitizer::escapeIdForAttribute( $this->mID . "-$info" );
$classes = [ 'mw-htmlform-flatlist-item' ];
- if ( $wgUseMediaWikiUIEverywhere || $this->mParent instanceof VFormHTMLForm ) {
+ if ( $useMediaWikiUIEverywhere || $this->mParent instanceof VFormHTMLForm ) {
$classes[] = 'mw-ui-radio';
}
$radio = Xml::radio( $this->mName, $info, $info === $value, $attribs + [ 'id' => $id ] );
diff --git a/includes/htmlform/fields/HTMLSelectLanguageField.php b/includes/htmlform/fields/HTMLSelectLanguageField.php
index 0971a38d48f0..ada214591386 100644
--- a/includes/htmlform/fields/HTMLSelectLanguageField.php
+++ b/includes/htmlform/fields/HTMLSelectLanguageField.php
@@ -20,8 +20,7 @@ class HTMLSelectLanguageField extends HTMLSelectField {
$config = $this->mParent->getConfig();
$languageCode = $config->get( 'LanguageCode' );
} else {
- global $wgLanguageCode;
- $languageCode = $wgLanguageCode;
+ $languageCode = MediaWikiServices::getInstance()->getMainConfig()->get( 'LanguageCode' );
}
$languages = MediaWikiServices::getInstance()
diff --git a/includes/http/Http.php b/includes/http/Http.php
index e30fd1935a6f..945897c1e515 100644
--- a/includes/http/Http.php
+++ b/includes/http/Http.php
@@ -124,8 +124,8 @@ class Http {
public static function getProxy() {
wfDeprecated( __METHOD__, '1.34' );
- global $wgHTTPProxy;
- return (string)$wgHTTPProxy;
+ $httpProxy = MediaWikiServices::getInstance()->getMainConfig()->get( 'HTTPProxy' );
+ return (string)$httpProxy;
}
/**
@@ -137,8 +137,8 @@ class Http {
*/
public static function createMultiClient( array $options = [] ) {
wfDeprecated( __METHOD__, '1.34' );
- global $wgHTTPProxy;
+ $httpProxy = MediaWikiServices::getInstance()->getMainConfig()->get( 'HTTPProxy' );
return MediaWikiServices::getInstance()->getHttpRequestFactory()
- ->createMultiClient( $options + [ 'proxy' => $wgHTTPProxy ] );
+ ->createMultiClient( $options + [ 'proxy' => $httpProxy ] );
}
}
diff --git a/includes/http/MWHttpRequest.php b/includes/http/MWHttpRequest.php
index 531b5b051f7c..3ac63d258c42 100644
--- a/includes/http/MWHttpRequest.php
+++ b/includes/http/MWHttpRequest.php
@@ -115,8 +115,8 @@ abstract class MWHttpRequest implements LoggerAwareInterface {
// The timeout should always be set by HttpRequestFactory, so this
// should only happen if the class was directly constructed
wfDeprecated( __METHOD__ . ' without the timeout option', '1.35' );
- global $wgHTTPTimeout;
- $this->timeout = $wgHTTPTimeout;
+ $httpTimeout = MediaWikiServices::getInstance()->getMainConfig()->get( 'HTTPTimeout' );
+ $this->timeout = $httpTimeout;
}
if ( isset( $options['connectTimeout'] ) && $options['connectTimeout'] != 'default' ) {
$this->connectTimeout = $options['connectTimeout'];
@@ -124,8 +124,8 @@ abstract class MWHttpRequest implements LoggerAwareInterface {
// The timeout should always be set by HttpRequestFactory, so this
// should only happen if the class was directly constructed
wfDeprecated( __METHOD__ . ' without the connectTimeout option', '1.35' );
- global $wgHTTPConnectTimeout;
- $this->connectTimeout = $wgHTTPConnectTimeout;
+ $httpConnectTimeout = MediaWikiServices::getInstance()->getMainConfig()->get( 'HTTPConnectTimeout' );
+ $this->connectTimeout = $httpConnectTimeout;
}
if ( isset( $options['userAgent'] ) ) {
$this->setUserAgent( $options['userAgent'] );
@@ -224,7 +224,8 @@ abstract class MWHttpRequest implements LoggerAwareInterface {
* @return void
*/
protected function proxySetup() {
- global $wgHTTPProxy, $wgLocalHTTPProxy;
+ $httpProxy = MediaWikiServices::getInstance()->getMainConfig()->get( 'HTTPProxy' );
+ $localHTTPProxy = MediaWikiServices::getInstance()->getMainConfig()->get( 'LocalHTTPProxy' );
// If proxies are disabled, clear any other proxy
if ( $this->noProxy ) {
$this->proxy = '';
@@ -239,11 +240,11 @@ abstract class MWHttpRequest implements LoggerAwareInterface {
// Otherwise, fallback to $wgLocalHTTPProxy for local URLs
// or $wgHTTPProxy for everything else
if ( self::isLocalURL( $this->url ) ) {
- if ( $wgLocalHTTPProxy !== false ) {
- $this->setReverseProxy( $wgLocalHTTPProxy );
+ if ( $localHTTPProxy !== false ) {
+ $this->setReverseProxy( $localHTTPProxy );
}
} else {
- $this->proxy = (string)$wgHTTPProxy;
+ $this->proxy = (string)$httpProxy;
}
}
@@ -284,9 +285,9 @@ abstract class MWHttpRequest implements LoggerAwareInterface {
* @return bool
*/
private static function isLocalURL( $url ) {
- global $wgCommandLineMode, $wgLocalVirtualHosts;
-
- if ( $wgCommandLineMode ) {
+ $commandLineMode = MediaWikiServices::getInstance()->getMainConfig()->get( 'CommandLineMode' );
+ $localVirtualHosts = MediaWikiServices::getInstance()->getMainConfig()->get( 'LocalVirtualHosts' );
+ if ( $commandLineMode ) {
return false;
}
@@ -309,7 +310,7 @@ abstract class MWHttpRequest implements LoggerAwareInterface {
$domain = $domainPart . '.' . $domain;
}
- if ( in_array( $domain, $wgLocalVirtualHosts ) ) {
+ if ( in_array( $domain, $localVirtualHosts ) ) {
return true;
}
}
diff --git a/includes/import/ImportStreamSource.php b/includes/import/ImportStreamSource.php
index 9f9cf7be2df2..ec05f2709998 100644
--- a/includes/import/ImportStreamSource.php
+++ b/includes/import/ImportStreamSource.php
@@ -23,6 +23,7 @@
* @file
* @ingroup SpecialPage
*/
+
use MediaWiki\MediaWikiServices;
/**
@@ -112,7 +113,7 @@ class ImportStreamSource implements ImportSource {
* @return Status
*/
public static function newFromURL( $url, $method = 'GET' ) {
- global $wgHTTPImportTimeout;
+ $httpImportTimeout = MediaWikiServices::getInstance()->getMainConfig()->get( 'HTTPImportTimeout' );
wfDebug( __METHOD__ . ": opening $url" );
# Use the standard HTTP fetch function; it times out
# quicker and sorts out user-agent problems which might
@@ -123,7 +124,7 @@ class ImportStreamSource implements ImportSource {
$url,
[
'followRedirects' => true,
- 'timeout' => $wgHTTPImportTimeout
+ 'timeout' => $httpImportTimeout
],
__METHOD__
);
diff --git a/includes/import/WikiImporter.php b/includes/import/WikiImporter.php
index 5dce4dd85f62..a33f22f0d470 100644
--- a/includes/import/WikiImporter.php
+++ b/includes/import/WikiImporter.php
@@ -28,6 +28,7 @@ use MediaWiki\Cache\CacheKeyHelper;
use MediaWiki\Content\IContentHandlerFactory;
use MediaWiki\HookContainer\HookContainer;
use MediaWiki\HookContainer\HookRunner;
+use MediaWiki\MediaWikiServices;
use MediaWiki\Page\PageIdentity;
use MediaWiki\Page\WikiPageFactory;
use MediaWiki\Permissions\PermissionManager;
@@ -1039,7 +1040,7 @@ class WikiImporter {
* @throws MWException
*/
private function makeContent( Title $title, $revisionId, $contentInfo ) {
- global $wgMaxArticleSize;
+ $maxArticleSize = MediaWikiServices::getInstance()->getMainConfig()->get( 'MaxArticleSize' );
if ( !isset( $contentInfo['text'] ) ) {
throw new MWException( 'Missing text field in import.' );
@@ -1058,13 +1059,13 @@ class WikiImporter {
'text',
''
] ) ) &&
- strlen( $contentInfo['text'] ) > $wgMaxArticleSize * 1024
+ strlen( $contentInfo['text'] ) > $maxArticleSize * 1024
) {
throw new MWException( 'The text of ' .
( $revisionId ?
"the revision with ID $revisionId" :
'a revision'
- ) . " exceeds the maximum allowable size ($wgMaxArticleSize KiB)" );
+ ) . " exceeds the maximum allowable size ({$maxArticleSize} KiB)" );
}
$role = $contentInfo['role'] ?? SlotRecord::MAIN;
diff --git a/includes/jobqueue/Job.php b/includes/jobqueue/Job.php
index 03cc2788fc2e..06edbd914203 100644
--- a/includes/jobqueue/Job.php
+++ b/includes/jobqueue/Job.php
@@ -21,6 +21,7 @@
* @defgroup JobQueue JobQueue
*/
+use MediaWiki\MediaWikiServices;
use MediaWiki\Page\PageReference;
/**
@@ -68,7 +69,7 @@ abstract class Job implements RunnableJob {
* @return Job
*/
public static function factory( $command, $params = [] ) {
- global $wgJobClasses;
+ $jobClasses = MediaWikiServices::getInstance()->getMainConfig()->get( 'JobClasses' );
if ( $params instanceof PageReference ) {
// Backwards compatibility for old signature ($command, $title, $params)
@@ -87,8 +88,8 @@ abstract class Job implements RunnableJob {
$title = Title::makeTitle( NS_SPECIAL, 'Blankpage' );
}
- if ( isset( $wgJobClasses[$command] ) ) {
- $handler = $wgJobClasses[$command];
+ if ( isset( $jobClasses[$command] ) ) {
+ $handler = $jobClasses[$command];
if ( is_callable( $handler ) ) {
$job = call_user_func( $handler, $title, $params );
diff --git a/includes/jobqueue/JobQueueGroup.php b/includes/jobqueue/JobQueueGroup.php
index 2fb99d7fcb02..06f2a0f4d0ff 100644
--- a/includes/jobqueue/JobQueueGroup.php
+++ b/includes/jobqueue/JobQueueGroup.php
@@ -472,9 +472,9 @@ class JobQueueGroup {
$cache->makeGlobalKey( 'jobqueue', 'configvalue', $this->domain, $name ),
$cache::TTL_DAY + mt_rand( 0, $cache::TTL_DAY ),
static function () use ( $wiki, $name ) {
- global $wgConf;
+ $conf = MediaWikiServices::getInstance()->getMainConfig()->get( 'Conf' );
// @TODO: use the full domain ID here
- return [ 'v' => $wgConf->getConfig( $wiki, $name ) ];
+ return [ 'v' => $conf->getConfig( $wiki, $name ) ];
},
[ 'pcTTL' => WANObjectCache::TTL_PROC_LONG ]
);
diff --git a/includes/jobqueue/jobs/ClearUserWatchlistJob.php b/includes/jobqueue/jobs/ClearUserWatchlistJob.php
index c0a86f5e03e6..8c0d5a7645aa 100644
--- a/includes/jobqueue/jobs/ClearUserWatchlistJob.php
+++ b/includes/jobqueue/jobs/ClearUserWatchlistJob.php
@@ -34,10 +34,10 @@ class ClearUserWatchlistJob extends Job implements GenericParameterJob {
}
public function run() {
- global $wgUpdateRowsPerQuery;
+ $updateRowsPerQuery = MediaWikiServices::getInstance()->getMainConfig()->get( 'UpdateRowsPerQuery' );
$userId = $this->params['userId'];
$maxWatchlistId = $this->params['maxWatchlistId'];
- $batchSize = $wgUpdateRowsPerQuery;
+ $batchSize = $updateRowsPerQuery;
$loadBalancer = MediaWikiServices::getInstance()->getDBLoadBalancer();
$dbw = $loadBalancer->getConnectionRef( DB_PRIMARY );
diff --git a/includes/jobqueue/jobs/HTMLCacheUpdateJob.php b/includes/jobqueue/jobs/HTMLCacheUpdateJob.php
index 11851330a62b..ccbc37e4f50e 100644
--- a/includes/jobqueue/jobs/HTMLCacheUpdateJob.php
+++ b/includes/jobqueue/jobs/HTMLCacheUpdateJob.php
@@ -72,8 +72,8 @@ class HTMLCacheUpdateJob extends Job {
}
public function run() {
- global $wgUpdateRowsPerJob, $wgUpdateRowsPerQuery;
-
+ $updateRowsPerJob = MediaWikiServices::getInstance()->getMainConfig()->get( 'UpdateRowsPerJob' );
+ $updateRowsPerQuery = MediaWikiServices::getInstance()->getMainConfig()->get( 'UpdateRowsPerQuery' );
if ( isset( $this->params['table'] ) && !isset( $this->params['pages'] ) ) {
$this->params['recursive'] = true; // b/c; base job
}
@@ -89,8 +89,8 @@ class HTMLCacheUpdateJob extends Job {
// jobs and possibly a recursive HTMLCacheUpdateJob job for the rest of the backlinks
$jobs = BacklinkJobUtils::partitionBacklinkJob(
$this,
- $wgUpdateRowsPerJob,
- $wgUpdateRowsPerQuery, // jobs-per-title
+ $updateRowsPerJob,
+ $updateRowsPerQuery, // jobs-per-title
// Carry over information for de-duplication
[ 'params' => $extraParams ]
);
diff --git a/includes/jobqueue/jobs/RecentChangesUpdateJob.php b/includes/jobqueue/jobs/RecentChangesUpdateJob.php
index b08c7e2790d5..7abb44fcf06b 100644
--- a/includes/jobqueue/jobs/RecentChangesUpdateJob.php
+++ b/includes/jobqueue/jobs/RecentChangesUpdateJob.php
@@ -18,6 +18,7 @@
* @file
* @ingroup JobQueue
*/
+
use MediaWiki\MediaWikiServices;
/**
@@ -71,8 +72,8 @@ class RecentChangesUpdateJob extends Job {
}
protected function purgeExpiredRows() {
- global $wgRCMaxAge, $wgUpdateRowsPerQuery;
-
+ $rcMaxAge = MediaWikiServices::getInstance()->getMainConfig()->get( 'RCMaxAge' );
+ $updateRowsPerQuery = MediaWikiServices::getInstance()->getMainConfig()->get( 'UpdateRowsPerQuery' );
$dbw = wfGetDB( DB_PRIMARY );
$lockKey = $dbw->getDomainID() . ':recentchanges-prune';
if ( !$dbw->lock( $lockKey, __METHOD__, 0 ) ) {
@@ -82,7 +83,7 @@ class RecentChangesUpdateJob extends Job {
$factory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
$ticket = $factory->getEmptyTransactionTicket( __METHOD__ );
- $cutoff = $dbw->timestamp( time() - $wgRCMaxAge );
+ $cutoff = $dbw->timestamp( time() - $rcMaxAge );
$rcQuery = RecentChange::getQueryInfo();
do {
$rcIds = [];
@@ -92,7 +93,7 @@ class RecentChangesUpdateJob extends Job {
$rcQuery['fields'],
[ 'rc_timestamp < ' . $dbw->addQuotes( $cutoff ) ],
__METHOD__,
- [ 'LIMIT' => $wgUpdateRowsPerQuery ],
+ [ 'LIMIT' => $updateRowsPerQuery ],
$rcQuery['joins']
);
foreach ( $res as $row ) {
@@ -116,12 +117,12 @@ class RecentChangesUpdateJob extends Job {
}
protected function updateActiveUsers() {
- global $wgActiveUserDays;
+ $activeUserDays = MediaWikiServices::getInstance()->getMainConfig()->get( 'ActiveUserDays' );
// Users that made edits at least this many days ago are "active"
- $days = $wgActiveUserDays;
+ $days = $activeUserDays;
// Pull in the full window of active users in this update
- $window = $wgActiveUserDays * 86400;
+ $window = $activeUserDays * 86400;
$dbw = wfGetDB( DB_PRIMARY );
$factory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
diff --git a/includes/jobqueue/jobs/ThumbnailRenderJob.php b/includes/jobqueue/jobs/ThumbnailRenderJob.php
index 7f8911fa3ebe..529c55b775cf 100644
--- a/includes/jobqueue/jobs/ThumbnailRenderJob.php
+++ b/includes/jobqueue/jobs/ThumbnailRenderJob.php
@@ -34,7 +34,8 @@ class ThumbnailRenderJob extends Job {
}
public function run() {
- global $wgUploadThumbnailRenderMethod;
+ $uploadThumbnailRenderMethod = MediaWikiServices::getInstance()
+ ->getMainConfig()->get( 'UploadThumbnailRenderMethod' );
$transformParams = $this->params['transformParams'];
@@ -43,7 +44,7 @@ class ThumbnailRenderJob extends Job {
$file->load( File::READ_LATEST );
if ( $file && $file->exists() ) {
- if ( $wgUploadThumbnailRenderMethod === 'jobqueue' ) {
+ if ( $uploadThumbnailRenderMethod === 'jobqueue' ) {
$thumb = $file->transform( $transformParams, File::RENDER_NOW );
if ( !$thumb || $thumb->isError() ) {
@@ -56,11 +57,11 @@ class ThumbnailRenderJob extends Job {
return false;
}
return true;
- } elseif ( $wgUploadThumbnailRenderMethod === 'http' ) {
+ } elseif ( $uploadThumbnailRenderMethod === 'http' ) {
return $this->hitThumbUrl( $file, $transformParams );
} else {
$this->setLastError( __METHOD__ . ': unknown thumbnail render method ' .
- $wgUploadThumbnailRenderMethod );
+ $uploadThumbnailRenderMethod );
return false;
}
} else {
@@ -75,8 +76,9 @@ class ThumbnailRenderJob extends Job {
* @return bool Success status (error will be set via setLastError() when false)
*/
protected function hitThumbUrl( LocalFile $file, $transformParams ) {
- global $wgUploadThumbnailRenderHttpCustomHost, $wgUploadThumbnailRenderHttpCustomDomain;
-
+ $config = MediaWikiServices::getInstance()->getMainConfig();
+ $uploadThumbnailRenderHttpCustomHost = $config->get( 'UploadThumbnailRenderHttpCustomHost' );
+ $uploadThumbnailRenderHttpCustomDomain = $config->get( 'UploadThumbnailRenderHttpCustomDomain' );
$handler = $file->getHandler();
if ( !$handler ) {
$this->setLastError( __METHOD__ . ': could not get handler' );
@@ -93,7 +95,7 @@ class ThumbnailRenderJob extends Job {
return false;
}
- if ( $wgUploadThumbnailRenderHttpCustomDomain ) {
+ if ( $uploadThumbnailRenderHttpCustomDomain ) {
$parsedUrl = wfParseUrl( $thumbUrl );
if ( !isset( $parsedUrl['path'] ) || $parsedUrl['path'] === '' ) {
@@ -101,7 +103,7 @@ class ThumbnailRenderJob extends Job {
return false;
}
- $thumbUrl = '//' . $wgUploadThumbnailRenderHttpCustomDomain . $parsedUrl['path'];
+ $thumbUrl = '//' . $uploadThumbnailRenderHttpCustomDomain . $parsedUrl['path'];
}
wfDebug( __METHOD__ . ": hitting url {$thumbUrl}" );
@@ -114,8 +116,8 @@ class ThumbnailRenderJob extends Job {
__METHOD__
);
- if ( $wgUploadThumbnailRenderHttpCustomHost ) {
- $request->setHeader( 'Host', $wgUploadThumbnailRenderHttpCustomHost );
+ if ( $uploadThumbnailRenderHttpCustomHost ) {
+ $request->setHeader( 'Host', $uploadThumbnailRenderHttpCustomHost );
}
$status = $request->execute();
diff --git a/includes/language/Language.php b/includes/language/Language.php
index cba04ed917b3..07284cc98183 100644
--- a/includes/language/Language.php
+++ b/includes/language/Language.php
@@ -497,18 +497,21 @@ class Language {
*/
public function getNamespaces() {
if ( $this->namespaceNames === null ) {
- global $wgMetaNamespace, $wgMetaNamespaceTalk, $wgExtraNamespaces;
-
+ $mainConfig = MediaWikiServices::getInstance()->getMainConfig();
+ $metaNamespace = $mainConfig->get( 'MetaNamespace' );
+ $metaNamespaceTalk = $mainConfig->get( 'MetaNamespaceTalk' );
+ $extraNamespaces = $mainConfig->get( 'ExtraNamespaces' );
$validNamespaces = MediaWikiServices::getInstance()->getNamespaceInfo()->
getCanonicalNamespaces();
- $this->namespaceNames = $wgExtraNamespaces +
+ $this->namespaceNames = $extraNamespaces +
$this->localisationCache->getItem( $this->mCode, 'namespaceNames' );
+ // @phan-suppress-next-line PhanTypeInvalidLeftOperand
$this->namespaceNames += $validNamespaces;
- $this->namespaceNames[NS_PROJECT] = $wgMetaNamespace;
- if ( $wgMetaNamespaceTalk ) {
- $this->namespaceNames[NS_PROJECT_TALK] = $wgMetaNamespaceTalk;
+ $this->namespaceNames[NS_PROJECT] = $metaNamespace;
+ if ( $metaNamespaceTalk ) {
+ $this->namespaceNames[NS_PROJECT_TALK] = $metaNamespaceTalk;
} else {
$talk = $this->namespaceNames[NS_PROJECT_TALK];
$this->namespaceNames[NS_PROJECT_TALK] =
@@ -607,9 +610,9 @@ class Language {
* @since 1.18
*/
public function getGenderNsText( $index, $gender ) {
- global $wgExtraGenderNamespaces;
+ $extraGenderNamespaces = MediaWikiServices::getInstance()->getMainConfig()->get( 'ExtraGenderNamespaces' );
- $ns = $wgExtraGenderNamespaces +
+ $ns = $extraGenderNamespaces +
(array)$this->localisationCache->getItem( $this->mCode, 'namespaceGenderAliases' );
return $ns[$index][$gender] ?? $this->getNsText( $index );
@@ -622,11 +625,12 @@ class Language {
* @since 1.18
*/
public function needsGenderDistinction() {
- global $wgExtraGenderNamespaces, $wgExtraNamespaces;
- if ( count( $wgExtraGenderNamespaces ) > 0 ) {
+ $extraGenderNamespaces = MediaWikiServices::getInstance()->getMainConfig()->get( 'ExtraGenderNamespaces' );
+ $extraNamespaces = MediaWikiServices::getInstance()->getMainConfig()->get( 'ExtraNamespaces' );
+ if ( count( $extraGenderNamespaces ) > 0 ) {
// $wgExtraGenderNamespaces overrides everything
return true;
- } elseif ( isset( $wgExtraNamespaces[NS_USER] ) && isset( $wgExtraNamespaces[NS_USER_TALK] ) ) {
+ } elseif ( isset( $extraNamespaces[NS_USER] ) && isset( $extraNamespaces[NS_USER_TALK] ) ) {
// @todo There may be other gender namespace than NS_USER & NS_USER_TALK in the future
// $wgExtraNamespaces overrides any gender aliases specified in i18n files
return false;
@@ -670,8 +674,8 @@ class Language {
}
}
- global $wgExtraGenderNamespaces;
- $genders = $wgExtraGenderNamespaces + (array)$this->localisationCache
+ $extraGenderNamespaces = MediaWikiServices::getInstance()->getMainConfig()->get( 'ExtraGenderNamespaces' );
+ $genders = $extraGenderNamespaces + (array)$this->localisationCache
->getItem( $this->mCode, 'namespaceGenderAliases' );
foreach ( $genders as $index => $forms ) {
foreach ( $forms as $alias ) {
@@ -694,8 +698,8 @@ class Language {
// In the case of conflicts between $wgNamespaceAliases and other sources
// of aliasing, $wgNamespaceAliases wins.
- global $wgNamespaceAliases;
- $this->namespaceAliases = $wgNamespaceAliases + $this->namespaceAliases;
+ $namespaceAliases = MediaWikiServices::getInstance()->getMainConfig()->get( 'NamespaceAliases' );
+ $this->namespaceAliases = $namespaceAliases + $this->namespaceAliases;
# Filter out aliases to namespaces that don't exist, e.g. from extensions
# that aren't loaded here but are included in the l10n cache.
@@ -788,8 +792,8 @@ class Language {
public function getDefaultDateFormat() {
$df = $this->localisationCache->getItem( $this->mCode, 'defaultDateFormat' );
if ( $df === 'dmy or mdy' ) {
- global $wgAmericanDates;
- return $wgAmericanDates ? 'mdy' : 'dmy';
+ $americanDates = MediaWikiServices::getInstance()->getMainConfig()->get( 'AmericanDates' );
+ return $americanDates ? 'mdy' : 'dmy';
} else {
return $df;
}
@@ -2061,7 +2065,7 @@ class Language {
* @return string
*/
public function userAdjust( $ts, $tz = false ) {
- global $wgLocalTZoffset;
+ $localTZoffset = MediaWikiServices::getInstance()->getMainConfig()->get( 'LocalTZoffset' );
if ( $tz === false ) {
$optionsLookup = MediaWikiServices::getInstance()->getUserOptionsLookup();
@@ -2087,7 +2091,7 @@ class Language {
if ( $data[0] == 'System' || $tz == '' ) {
# Global offset in minutes.
- $minDiff = $wgLocalTZoffset;
+ $minDiff = $localTZoffset;
} elseif ( $data[0] == 'Offset' ) {
$minDiff = intval( $data[1] );
} else {
@@ -2672,9 +2676,10 @@ class Language {
* @return string
*/
protected function mbUpperChar( $char ) {
- global $wgOverrideUcfirstCharacters;
+ $overrideUcfirstCharacters = MediaWikiServices::getInstance()
+ ->getMainConfig()->get( 'OverrideUcfirstCharacters' );
- return $wgOverrideUcfirstCharacters[$char] ?? mb_strtoupper( $char );
+ return $overrideUcfirstCharacters[$char] ?? mb_strtoupper( $char );
}
/**
@@ -2957,11 +2962,11 @@ class Language {
* @return string
*/
public function normalize( $s ) {
- global $wgAllUnicodeFixes;
+ $allUnicodeFixes = MediaWikiServices::getInstance()->getMainConfig()->get( 'AllUnicodeFixes' );
$s = UtfNormal\Validator::cleanUp( $s );
// Optimization: This is disabled by default to avoid negative performance impact.
- if ( $wgAllUnicodeFixes ) {
+ if ( $allUnicodeFixes ) {
$s = $this->transformUsingPairFile( MediaWiki\Languages\Data\NormalizeAr::class, $s );
$s = $this->transformUsingPairFile( MediaWiki\Languages\Data\NormalizeMl::class, $s );
}
@@ -3194,7 +3199,7 @@ class Language {
private function formatNumInternal(
string $number, bool $noTranslate, bool $noSeparators
): string {
- global $wgTranslateNumerals;
+ $translateNumerals = MediaWikiServices::getInstance()->getMainConfig()->get( 'TranslateNumerals' );
if ( $number === '' ) {
return $number;
@@ -3230,7 +3235,7 @@ class Language {
$separatorTransformTable = $this->separatorTransformTable();
$digitGroupingPattern = $this->digitGroupingPattern();
$code = $this->getCode();
- if ( !( $wgTranslateNumerals && $this->langNameUtils->isValidCode( $code ) ) ) {
+ if ( !( $translateNumerals && $this->langNameUtils->isValidCode( $code ) ) ) {
$code = 'C'; // POSIX system default locale
}
@@ -3305,7 +3310,7 @@ class Language {
}
if ( !$noTranslate ) {
- if ( $wgTranslateNumerals ) {
+ if ( $translateNumerals ) {
// This is often unnecessary: PHP's NumberFormatter will often
// do the digit transform itself (T267614)
$s = $this->digitTransformTable();
@@ -3828,9 +3833,9 @@ class Language {
* @return string
*/
public function convertGrammar( $word, $case ) {
- global $wgGrammarForms;
- if ( isset( $wgGrammarForms[$this->getCode()][$case][$word] ) ) {
- return $wgGrammarForms[$this->getCode()][$case][$word];
+ $grammarForms = MediaWikiServices::getInstance()->getMainConfig()->get( 'GrammarForms' );
+ if ( isset( $grammarForms[$this->getCode()][$case][$word] ) ) {
+ return $grammarForms[$this->getCode()][$case][$word];
}
$grammarTransformations = $this->getGrammarTransformations();
@@ -3879,11 +3884,11 @@ class Language {
* @since 1.20
*/
public function getGrammarForms() {
- global $wgGrammarForms;
- if ( isset( $wgGrammarForms[$this->getCode()] )
- && is_array( $wgGrammarForms[$this->getCode()] )
+ $grammarForms = MediaWikiServices::getInstance()->getMainConfig()->get( 'GrammarForms' );
+ if ( isset( $grammarForms[$this->getCode()] )
+ && is_array( $grammarForms[$this->getCode()] )
) {
- return $wgGrammarForms[$this->getCode()];
+ return $grammarForms[$this->getCode()];
}
return [];
@@ -4511,8 +4516,8 @@ class Language {
return $talk;
}
- global $wgMetaNamespace;
- $talk = str_replace( '$1', $wgMetaNamespace, $talk );
+ $metaNamespace = MediaWikiServices::getInstance()->getMainConfig()->get( 'MetaNamespace' );
+ $talk = str_replace( '$1', $metaNamespace, $talk );
# Allow grammar transformations
# Allowing full message-style parsing would make simple requests
diff --git a/includes/language/LanguageConverter.php b/includes/language/LanguageConverter.php
index 2a72040e6e70..5ee8bbae8ca5 100644
--- a/includes/language/LanguageConverter.php
+++ b/includes/language/LanguageConverter.php
@@ -21,6 +21,7 @@
* @author shinjiman <shinjiman@gmail.com>
* @author PhiLiP <philip.npc@gmail.com>
*/
+
use MediaWiki\Linker\LinkTarget;
use MediaWiki\Logger\LoggerFactory;
use MediaWiki\MediaWikiServices;
@@ -253,8 +254,8 @@ abstract class LanguageConverter implements ILanguageConverter {
* @return string[] Contains all valid variants
*/
final public function getVariants() {
- global $wgDisabledVariants;
- return array_diff( $this->getLanguageVariants(), $wgDisabledVariants );
+ $disabledVariants = MediaWikiServices::getInstance()->getMainConfig()->get( 'DisabledVariants' );
+ return array_diff( $this->getLanguageVariants(), $disabledVariants );
}
/**
@@ -285,7 +286,7 @@ abstract class LanguageConverter implements ILanguageConverter {
* @return string The preferred language code
*/
public function getPreferredVariant() {
- global $wgDefaultLanguageVariant;
+ $defaultLanguageVariant = MediaWikiServices::getInstance()->getMainConfig()->get( 'DefaultLanguageVariant' );
$req = $this->getURLVariant();
@@ -302,8 +303,8 @@ abstract class LanguageConverter implements ILanguageConverter {
$req = $this->getHeaderVariant();
}
- if ( $wgDefaultLanguageVariant && !$req ) {
- $req = $this->validateVariant( $wgDefaultLanguageVariant );
+ if ( $defaultLanguageVariant && !$req ) {
+ $req = $this->validateVariant( $defaultLanguageVariant );
}
$req = $this->validateVariant( $req );
@@ -323,7 +324,7 @@ abstract class LanguageConverter implements ILanguageConverter {
* @return string The default variant code
*/
public function getDefaultVariant() {
- global $wgDefaultLanguageVariant;
+ $defaultLanguageVariant = MediaWikiServices::getInstance()->getMainConfig()->get( 'DefaultLanguageVariant' );
$req = $this->getURLVariant();
@@ -331,8 +332,8 @@ abstract class LanguageConverter implements ILanguageConverter {
$req = $this->getHeaderVariant();
}
- if ( $wgDefaultLanguageVariant && !$req ) {
- $req = $this->validateVariant( $wgDefaultLanguageVariant );
+ if ( $defaultLanguageVariant && !$req ) {
+ $req = $this->validateVariant( $defaultLanguageVariant );
}
if ( $req ) {
@@ -1090,7 +1091,8 @@ abstract class LanguageConverter implements ILanguageConverter {
* @param bool $fromCache Load from memcached? Defaults to true.
*/
protected function loadTables( $fromCache = true ) {
- global $wgLanguageConverterCacheType;
+ $languageConverterCacheType = MediaWikiServices::getInstance()
+ ->getMainConfig()->get( 'LanguageConverterCacheType' );
if ( $this->mTablesLoaded ) {
return;
@@ -1099,7 +1101,7 @@ abstract class LanguageConverter implements ILanguageConverter {
$this->mTablesLoaded = true;
// Do not use null as starting value, as that would confuse phan a lot.
$this->mTables = [];
- $cache = ObjectCache::getInstance( $wgLanguageConverterCacheType );
+ $cache = ObjectCache::getInstance( $languageConverterCacheType );
$cacheKey = $cache->makeKey( 'conversiontables', $this->getMainCode() );
if ( $fromCache ) {
$this->mTables = $cache->get( $cacheKey );
diff --git a/includes/language/Message.php b/includes/language/Message.php
index 7a10f62c6371..0ae0738e3895 100644
--- a/includes/language/Message.php
+++ b/includes/language/Message.php
@@ -454,14 +454,14 @@ class Message implements MessageSpecifier, Serializable {
* @since 1.26
*/
public function getTitle() {
- global $wgForceUIMsgAsContentMsg;
+ $forceUIMsgAsContentMsg = MediaWikiServices::getInstance()->getMainConfig()->get( 'ForceUIMsgAsContentMsg' );
$contLang = MediaWikiServices::getInstance()->getContentLanguage();
$lang = $this->getLanguage();
$title = $this->key;
if (
!$lang->equals( $contLang )
- && in_array( $this->key, (array)$wgForceUIMsgAsContentMsg )
+ && in_array( $this->key, (array)$forceUIMsgAsContentMsg )
) {
$title .= '/' . $lang->getCode();
}
@@ -842,8 +842,8 @@ class Message implements MessageSpecifier, Serializable {
* @return Message $this
*/
public function inContentLanguage() {
- global $wgForceUIMsgAsContentMsg;
- if ( in_array( $this->key, (array)$wgForceUIMsgAsContentMsg ) ) {
+ $forceUIMsgAsContentMsg = MediaWikiServices::getInstance()->getMainConfig()->get( 'ForceUIMsgAsContentMsg' );
+ if ( in_array( $this->key, (array)$forceUIMsgAsContentMsg ) ) {
return $this;
}
diff --git a/includes/languages/LanguageBs.php b/includes/languages/LanguageBs.php
index 36a0205beadc..523e941605ab 100644
--- a/includes/languages/LanguageBs.php
+++ b/includes/languages/LanguageBs.php
@@ -1,4 +1,5 @@
<?php
+
/**
* Bosnian (bosanski) specific code.
*
@@ -21,6 +22,8 @@
* @ingroup Language
*/
+use MediaWiki\MediaWikiServices;
+
/**
* Bosnian (bosanski)
*
@@ -39,9 +42,9 @@ class LanguageBs extends Language {
* @return string
*/
public function convertGrammar( $word, $case ) {
- global $wgGrammarForms;
- if ( isset( $wgGrammarForms['bs'][$case][$word] ) ) {
- return $wgGrammarForms['bs'][$case][$word];
+ $grammarForms = MediaWikiServices::getInstance()->getMainConfig()->get( 'GrammarForms' );
+ if ( isset( $grammarForms['bs'][$case][$word] ) ) {
+ return $grammarForms['bs'][$case][$word];
}
switch ( $case ) {
case 'instrumental': # instrumental
diff --git a/includes/languages/LanguageCu.php b/includes/languages/LanguageCu.php
index 038e436a6357..0144670fe6d2 100644
--- a/includes/languages/LanguageCu.php
+++ b/includes/languages/LanguageCu.php
@@ -1,4 +1,5 @@
<?php
+
/**
* Old Church Slavonic (Ѩзыкъ словѣньскъ) specific code.
*
@@ -21,6 +22,8 @@
* @ingroup Language
*/
+use MediaWiki\MediaWikiServices;
+
/**
* Old Church Slavonic (Ѩзыкъ словѣньскъ)
*
@@ -36,10 +39,10 @@ class LanguageCu extends Language {
* @return string
*/
public function convertGrammar( $word, $case ) {
- global $wgGrammarForms;
+ $grammarForms = MediaWikiServices::getInstance()->getMainConfig()->get( 'GrammarForms' );
- if ( isset( $wgGrammarForms['сu'][$case][$word] ) ) {
- return $wgGrammarForms['сu'][$case][$word];
+ if ( isset( $grammarForms['сu'][$case][$word] ) ) {
+ return $grammarForms['сu'][$case][$word];
}
# These rules are not perfect, but they are currently only used for
diff --git a/includes/languages/LanguageDsb.php b/includes/languages/LanguageDsb.php
index 3c62758e818c..d8630711d0d4 100644
--- a/includes/languages/LanguageDsb.php
+++ b/includes/languages/LanguageDsb.php
@@ -1,4 +1,5 @@
<?php
+
/**
* Lower Sorbian (Dolnoserbski) specific code.
*
@@ -22,6 +23,8 @@
* @ingroup Language
*/
+use MediaWiki\MediaWikiServices;
+
/**
* Lower Sorbian (Dolnoserbski)
*
@@ -37,9 +40,9 @@ class LanguageDsb extends Language {
* @return string
*/
public function convertGrammar( $word, $case ) {
- global $wgGrammarForms;
- if ( isset( $wgGrammarForms['dsb'][$case][$word] ) ) {
- return $wgGrammarForms['dsb'][$case][$word];
+ $grammarForms = MediaWikiServices::getInstance()->getMainConfig()->get( 'GrammarForms' );
+ if ( isset( $grammarForms['dsb'][$case][$word] ) ) {
+ return $grammarForms['dsb'][$case][$word];
}
switch ( $case ) {
diff --git a/includes/languages/LanguageFi.php b/includes/languages/LanguageFi.php
index cbde3d215b36..77fc999724a3 100644
--- a/includes/languages/LanguageFi.php
+++ b/includes/languages/LanguageFi.php
@@ -22,6 +22,7 @@
* @ingroup Language
*/
+use MediaWiki\MediaWikiServices;
use MediaWiki\User\UserIdentity;
/**
@@ -39,9 +40,9 @@ class LanguageFi extends Language {
* @return string
*/
public function convertGrammar( $word, $case ) {
- global $wgGrammarForms;
- if ( isset( $wgGrammarForms['fi'][$case][$word] ) ) {
- return $wgGrammarForms['fi'][$case][$word];
+ $grammarForms = MediaWikiServices::getInstance()->getMainConfig()->get( 'GrammarForms' );
+ if ( isset( $grammarForms['fi'][$case][$word] ) ) {
+ return $grammarForms['fi'][$case][$word];
}
# These rules don't cover the whole language.
diff --git a/includes/languages/LanguageGa.php b/includes/languages/LanguageGa.php
index 65e77985d5a4..e7f40c1042e8 100644
--- a/includes/languages/LanguageGa.php
+++ b/includes/languages/LanguageGa.php
@@ -1,4 +1,5 @@
<?php
+
/**
* Irish (Gaeilge) specific code.
*
@@ -21,6 +22,8 @@
* @ingroup Language
*/
+use MediaWiki\MediaWikiServices;
+
/**
* Irish (Gaeilge)
*
@@ -37,9 +40,9 @@ class LanguageGa extends Language {
* @return string
*/
public function convertGrammar( $word, $case ) {
- global $wgGrammarForms;
- if ( isset( $wgGrammarForms['ga'][$case][$word] ) ) {
- return $wgGrammarForms['ga'][$case][$word];
+ $grammarForms = MediaWikiServices::getInstance()->getMainConfig()->get( 'GrammarForms' );
+ if ( isset( $grammarForms['ga'][$case][$word] ) ) {
+ return $grammarForms['ga'][$case][$word];
}
switch ( $case ) {
diff --git a/includes/languages/LanguageHsb.php b/includes/languages/LanguageHsb.php
index d8abab3bed79..2868bbfc8efb 100644
--- a/includes/languages/LanguageHsb.php
+++ b/includes/languages/LanguageHsb.php
@@ -1,4 +1,5 @@
<?php
+
/**
* Upper Sorbian (Hornjoserbsce) specific code.
*
@@ -21,6 +22,8 @@
* @ingroup Language
*/
+use MediaWiki\MediaWikiServices;
+
/**
* Upper Sorbian (Hornjoserbsce)
*
@@ -36,9 +39,9 @@ class LanguageHsb extends Language {
* @return string
*/
public function convertGrammar( $word, $case ) {
- global $wgGrammarForms;
- if ( isset( $wgGrammarForms['hsb'][$case][$word] ) ) {
- return $wgGrammarForms['hsb'][$case][$word];
+ $grammarForms = MediaWikiServices::getInstance()->getMainConfig()->get( 'GrammarForms' );
+ if ( isset( $grammarForms['hsb'][$case][$word] ) ) {
+ return $grammarForms['hsb'][$case][$word];
}
switch ( $case ) {
diff --git a/includes/languages/LanguageHu.php b/includes/languages/LanguageHu.php
index 1a1754fdeae7..7c2a8dbdb6d6 100644
--- a/includes/languages/LanguageHu.php
+++ b/includes/languages/LanguageHu.php
@@ -1,4 +1,5 @@
<?php
+
/**
* Hungarian (magyar) specific code.
*
@@ -21,6 +22,8 @@
* @ingroup Language
*/
+use MediaWiki\MediaWikiServices;
+
/**
* Hungarian localisation for MediaWiki
*
@@ -34,9 +37,9 @@ class LanguageHu extends Language {
* @return string
*/
public function convertGrammar( $word, $case ) {
- global $wgGrammarForms;
- if ( isset( $wgGrammarForms[$this->getCode()][$case][$word] ) ) {
- return $wgGrammarForms[$this->getCode()][$case][$word];
+ $grammarForms = MediaWikiServices::getInstance()->getMainConfig()->get( 'GrammarForms' );
+ if ( isset( $grammarForms[$this->getCode()][$case][$word] ) ) {
+ return $grammarForms[$this->getCode()][$case][$word];
}
switch ( $case ) {
diff --git a/includes/languages/LanguageHy.php b/includes/languages/LanguageHy.php
index 36428f6ab169..56c5da0c9f86 100644
--- a/includes/languages/LanguageHy.php
+++ b/includes/languages/LanguageHy.php
@@ -1,4 +1,5 @@
<?php
+
/**
* Armenian (Հայերեն) specific code.
*
@@ -22,6 +23,8 @@
* @ingroup Language
*/
+use MediaWiki\MediaWikiServices;
+
/**
* Armenian (Հայերեն)
*
@@ -38,9 +41,9 @@ class LanguageHy extends Language {
* @return string
*/
public function convertGrammar( $word, $case ) {
- global $wgGrammarForms;
- if ( isset( $wgGrammarForms['hy'][$case][$word] ) ) {
- return $wgGrammarForms['hy'][$case][$word];
+ $grammarForms = MediaWikiServices::getInstance()->getMainConfig()->get( 'GrammarForms' );
+ if ( isset( $grammarForms['hy'][$case][$word] ) ) {
+ return $grammarForms['hy'][$case][$word];
}
# These rules are not perfect, but they are currently only used for site names so it doesn't
diff --git a/includes/languages/LanguageKaa.php b/includes/languages/LanguageKaa.php
index 2442bd232db8..9e059c7c4224 100644
--- a/includes/languages/LanguageKaa.php
+++ b/includes/languages/LanguageKaa.php
@@ -1,4 +1,5 @@
<?php
+
/**
* Karakalpak (Qaraqalpaqsha) specific code.
*
@@ -21,6 +22,8 @@
* @ingroup Language
*/
+use MediaWiki\MediaWikiServices;
+
/**
* Karakalpak (Qaraqalpaqsha)
*
@@ -40,9 +43,9 @@ class LanguageKaa extends Language {
* @return string
*/
public function convertGrammar( $word, $case ) {
- global $wgGrammarForms;
- if ( isset( $wgGrammarForms['kaa'][$case][$word] ) ) {
- return $wgGrammarForms['kaa'][$case][$word];
+ $grammarForms = MediaWikiServices::getInstance()->getMainConfig()->get( 'GrammarForms' );
+ if ( isset( $grammarForms['kaa'][$case][$word] ) ) {
+ return $grammarForms['kaa'][$case][$word];
}
/* Full code of function convertGrammar() is in development. Updates coming soon. */
return $word;
diff --git a/includes/languages/LanguageKk_cyrl.php b/includes/languages/LanguageKk_cyrl.php
index 8a89b4a9d5b7..e84c9f1fecfe 100644
--- a/includes/languages/LanguageKk_cyrl.php
+++ b/includes/languages/LanguageKk_cyrl.php
@@ -1,4 +1,7 @@
<?php
+
+use MediaWiki\MediaWikiServices;
+
/**
* Kazakh (Қазақша) specific code.
*
@@ -20,7 +23,6 @@
* @file
* @ingroup Language
*/
-
/**
* Kazakh (Қазақша)
*
@@ -40,12 +42,12 @@ class LanguageKk_cyrl extends Language {
* @return string
*/
protected function convertGrammarKk_cyrl( $word, $case ) {
- global $wgGrammarForms;
- if ( isset( $wgGrammarForms['kk-kz'][$case][$word] ) ) {
- return $wgGrammarForms['kk-kz'][$case][$word];
+ $grammarForms = MediaWikiServices::getInstance()->getMainConfig()->get( 'GrammarForms' );
+ if ( isset( $grammarForms['kk-kz'][$case][$word] ) ) {
+ return $grammarForms['kk-kz'][$case][$word];
}
- if ( isset( $wgGrammarForms['kk-cyrl'][$case][$word] ) ) {
- return $wgGrammarForms['kk-cyrl'][$case][$word];
+ if ( isset( $grammarForms['kk-cyrl'][$case][$word] ) ) {
+ return $grammarForms['kk-cyrl'][$case][$word];
}
// Set up some constants...
// Vowels in last syllable
@@ -272,12 +274,12 @@ class LanguageKk_cyrl extends Language {
* @return string
*/
protected function convertGrammarKk_latn( $word, $case ) {
- global $wgGrammarForms;
- if ( isset( $wgGrammarForms['kk-tr'][$case][$word] ) ) {
- return $wgGrammarForms['kk-tr'][$case][$word];
+ $grammarForms = MediaWikiServices::getInstance()->getMainConfig()->get( 'GrammarForms' );
+ if ( isset( $grammarForms['kk-tr'][$case][$word] ) ) {
+ return $grammarForms['kk-tr'][$case][$word];
}
- if ( isset( $wgGrammarForms['kk-latn'][$case][$word] ) ) {
- return $wgGrammarForms['kk-latn'][$case][$word];
+ if ( isset( $grammarForms['kk-latn'][$case][$word] ) ) {
+ return $grammarForms['kk-latn'][$case][$word];
}
// Set up some constants...
// Vowels in last syllable
@@ -504,12 +506,12 @@ class LanguageKk_cyrl extends Language {
* @return string
*/
protected function convertGrammarKk_arab( $word, $case ) {
- global $wgGrammarForms;
- if ( isset( $wgGrammarForms['kk-cn'][$case][$word] ) ) {
- return $wgGrammarForms['kk-cn'][$case][$word];
+ $grammarForms = MediaWikiServices::getInstance()->getMainConfig()->get( 'GrammarForms' );
+ if ( isset( $grammarForms['kk-cn'][$case][$word] ) ) {
+ return $grammarForms['kk-cn'][$case][$word];
}
- if ( isset( $wgGrammarForms['kk-arab'][$case][$word] ) ) {
- return $wgGrammarForms['kk-arab'][$case][$word];
+ if ( isset( $grammarForms['kk-arab'][$case][$word] ) ) {
+ return $grammarForms['kk-arab'][$case][$word];
}
// Set up some constants...
// Vowels in last syllable
diff --git a/includes/languages/LanguageLa.php b/includes/languages/LanguageLa.php
index 58f39baa2ec3..8c84623015dd 100644
--- a/includes/languages/LanguageLa.php
+++ b/includes/languages/LanguageLa.php
@@ -1,4 +1,5 @@
<?php
+
/**
* Latin (lingua Latina) specific code.
*
@@ -21,6 +22,8 @@
* @ingroup Language
*/
+use MediaWiki\MediaWikiServices;
+
/**
* Latin (lingua Latina)
*
@@ -41,9 +44,9 @@ class LanguageLa extends Language {
* @return string
*/
public function convertGrammar( $word, $case ) {
- global $wgGrammarForms;
- if ( isset( $wgGrammarForms['la'][$case][$word] ) ) {
- return $wgGrammarForms['la'][$case][$word];
+ $grammarForms = MediaWikiServices::getInstance()->getMainConfig()->get( 'GrammarForms' );
+ if ( isset( $grammarForms['la'][$case][$word] ) ) {
+ return $grammarForms['la'][$case][$word];
}
switch ( $case ) {
diff --git a/includes/languages/LanguageOs.php b/includes/languages/LanguageOs.php
index 16ab0d43777d..29989c354e74 100644
--- a/includes/languages/LanguageOs.php
+++ b/includes/languages/LanguageOs.php
@@ -1,4 +1,5 @@
<?php
+
/**
* Ossetian (Ирон) specific code.
*
@@ -22,6 +23,8 @@
* @ingroup Language
*/
+use MediaWiki\MediaWikiServices;
+
/**
* Ossetian (Ирон)
*
@@ -54,9 +57,9 @@ class LanguageOs extends Language {
* @return string
*/
public function convertGrammar( $word, $case ) {
- global $wgGrammarForms;
- if ( isset( $wgGrammarForms['os'][$case][$word] ) ) {
- return $wgGrammarForms['os'][$case][$word];
+ $grammarForms = MediaWikiServices::getInstance()->getMainConfig()->get( 'GrammarForms' );
+ if ( isset( $grammarForms['os'][$case][$word] ) ) {
+ return $grammarForms['os'][$case][$word];
}
# Ending for allative case
$end_allative = 'мæ';
diff --git a/includes/languages/LanguageSl.php b/includes/languages/LanguageSl.php
index f3ccf8e4c8cd..e7dc27a64c83 100644
--- a/includes/languages/LanguageSl.php
+++ b/includes/languages/LanguageSl.php
@@ -1,4 +1,5 @@
<?php
+
/**
* Slovenian (Slovenščina) specific code.
*
@@ -21,6 +22,8 @@
* @ingroup Language
*/
+use MediaWiki\MediaWikiServices;
+
/**
* Slovenian (Slovenščina)
*
@@ -39,9 +42,9 @@ class LanguageSl extends Language {
* @return string
*/
public function convertGrammar( $word, $case ) {
- global $wgGrammarForms;
- if ( isset( $wgGrammarForms['sl'][$case][$word] ) ) {
- return $wgGrammarForms['sl'][$case][$word];
+ $grammarForms = MediaWikiServices::getInstance()->getMainConfig()->get( 'GrammarForms' );
+ if ( isset( $grammarForms['sl'][$case][$word] ) ) {
+ return $grammarForms['sl'][$case][$word];
}
switch ( $case ) {
diff --git a/includes/languages/LanguageTyv.php b/includes/languages/LanguageTyv.php
index 7b10c9023017..4a7ed39019ca 100644
--- a/includes/languages/LanguageTyv.php
+++ b/includes/languages/LanguageTyv.php
@@ -1,4 +1,5 @@
<?php
+
/**
* Tyvan (Тыва дыл) specific code.
*
@@ -21,6 +22,8 @@
* @ingroup Language
*/
+use MediaWiki\MediaWikiServices;
+
/**
* Tyvan localization (Тыва дыл)
*
@@ -38,9 +41,9 @@ class LanguageTyv extends Language {
* @return string
*/
public function convertGrammar( $word, $case ) {
- global $wgGrammarForms;
- if ( isset( $wgGrammarForms['tyv'][$case][$word] ) ) {
- return $wgGrammarForms['tyv'][$case][$word];
+ $grammarForms = MediaWikiServices::getInstance()->getMainConfig()->get( 'GrammarForms' );
+ if ( isset( $grammarForms['tyv'][$case][$word] ) ) {
+ return $grammarForms['tyv'][$case][$word];
}
// Set up some constants...
diff --git a/includes/logging/LogEventsList.php b/includes/logging/LogEventsList.php
index f5094d579b27..2faeec8265df 100644
--- a/includes/logging/LogEventsList.php
+++ b/includes/logging/LogEventsList.php
@@ -784,7 +784,7 @@ class LogEventsList extends ContextSource {
* @throws InvalidArgumentException
*/
public static function getExcludeClause( $db, $audience = 'public', Authority $performer = null ) {
- global $wgLogRestrictions;
+ $logRestrictions = MediaWikiServices::getInstance()->getMainConfig()->get( 'LogRestrictions' );
if ( $audience != 'public' && $performer === null ) {
throw new InvalidArgumentException(
@@ -796,7 +796,7 @@ class LogEventsList extends ContextSource {
$hiddenLogs = [];
// Don't show private logs to unprivileged users
- foreach ( $wgLogRestrictions as $logType => $right ) {
+ foreach ( $logRestrictions as $logType => $right ) {
if ( $audience == 'public' || !$performer->isAllowed( $right )
) {
$hiddenLogs[] = $logType;
diff --git a/includes/logging/LogFormatter.php b/includes/logging/LogFormatter.php
index 5de61e432ae9..28679068cb73 100644
--- a/includes/logging/LogFormatter.php
+++ b/includes/logging/LogFormatter.php
@@ -22,6 +22,7 @@
* @license GPL-2.0-or-later
* @since 1.19
*/
+
use MediaWiki\Linker\LinkRenderer;
use MediaWiki\Linker\LinkTarget;
use MediaWiki\MediaWikiServices;
@@ -52,10 +53,10 @@ class LogFormatter {
* @return LogFormatter
*/
public static function newFromEntry( LogEntry $entry ) {
- global $wgLogActionsHandlers;
+ $logActionsHandlers = MediaWikiServices::getInstance()->getMainConfig()->get( 'LogActionsHandlers' );
$fulltype = $entry->getFullType();
$wildcard = $entry->getType() . '/*';
- $handler = $wgLogActionsHandlers[$fulltype] ?? $wgLogActionsHandlers[$wildcard] ?? '';
+ $handler = $logActionsHandlers[$fulltype] ?? $logActionsHandlers[$wildcard] ?? '';
if ( $handler !== '' && is_string( $handler ) && class_exists( $handler ) ) {
return new $handler( $entry );
diff --git a/includes/logging/LogPage.php b/includes/logging/LogPage.php
index 8e553e5888fe..ca3af28633f3 100644
--- a/includes/logging/LogPage.php
+++ b/includes/logging/LogPage.php
@@ -96,7 +96,7 @@ class LogPage {
* @return int The log_id of the inserted log entry
*/
protected function saveContent() {
- global $wgLogRestrictions;
+ $logRestrictions = MediaWikiServices::getInstance()->getMainConfig()->get( 'LogRestrictions' );
$dbw = wfGetDB( DB_PRIMARY );
@@ -133,7 +133,7 @@ class LogPage {
);
} elseif ( $this->sendToUDP ) {
# Don't send private logs to UDP
- if ( isset( $wgLogRestrictions[$this->type] ) && $wgLogRestrictions[$this->type] != '*' ) {
+ if ( isset( $logRestrictions[$this->type] ) && $logRestrictions[$this->type] != '*' ) {
return $newId;
}
@@ -206,9 +206,9 @@ class LogPage {
* @return string[]
*/
public static function validTypes() {
- global $wgLogTypes;
+ $logTypes = MediaWikiServices::getInstance()->getMainConfig()->get( 'LogTypes' );
- return $wgLogTypes;
+ return $logTypes;
}
/**
@@ -237,11 +237,11 @@ class LogPage {
public static function actionText( $type, $action, $title = null, $skin = null,
$params = [], $filterWikilinks = false
) {
- global $wgLang, $wgLogActions;
-
+ global $wgLang;
+ $logActions = MediaWikiServices::getInstance()->getMainConfig()->get( 'LogActions' );
$key = "$type/$action";
- if ( isset( $wgLogActions[$key] ) ) {
+ if ( isset( $logActions[$key] ) ) {
if ( $skin === null ) {
$langObj = MediaWikiServices::getInstance()->getContentLanguage();
$langObjOrNull = null;
@@ -252,28 +252,27 @@ class LogPage {
$langObjOrNull = $wgLang;
}
if ( $title === null ) {
- $rv = wfMessage( $wgLogActions[$key] )->inLanguage( $langObj )->escaped();
+ $rv = wfMessage( $logActions[$key] )->inLanguage( $langObj )->escaped();
} else {
$titleLink = self::getTitleLink( $title, $langObjOrNull );
if ( count( $params ) == 0 ) {
// @phan-suppress-next-line SecurityCheck-XSS
- $rv = wfMessage( $wgLogActions[$key] )->rawParams( $titleLink )
+ $rv = wfMessage( $logActions[$key] )->rawParams( $titleLink )
->inLanguage( $langObj )->escaped();
} else {
array_unshift( $params, $titleLink );
- $rv = wfMessage( $wgLogActions[$key] )->rawParams( $params )
+ $rv = wfMessage( $logActions[$key] )->rawParams( $params )
->inLanguage( $langObj )->escaped();
}
}
} else {
- global $wgLogActionsHandlers;
+ $logActionsHandlers = MediaWikiServices::getInstance()->getMainConfig()->get( 'LogActionsHandlers' );
- if ( isset( $wgLogActionsHandlers[$key] ) ) {
+ if ( isset( $logActionsHandlers[$key] ) ) {
$args = func_get_args();
- // @phan-suppress-next-line PhanTypeMismatchArgumentInternal
- $rv = call_user_func_array( $wgLogActionsHandlers[$key], $args );
+ $rv = call_user_func_array( $logActionsHandlers[$key], $args );
} else {
wfDebug( "LogPage::actionText - unknown action $key" );
$rv = "$action";
@@ -442,10 +441,10 @@ class LogPage {
* @since 1.19
*/
public function getName() {
- global $wgLogNames;
+ $logNames = MediaWikiServices::getInstance()->getMainConfig()->get( 'LogNames' );
// BC
- $key = $wgLogNames[$this->type] ?? 'log-name-' . $this->type;
+ $key = $logNames[$this->type] ?? 'log-name-' . $this->type;
return wfMessage( $key );
}
@@ -456,9 +455,9 @@ class LogPage {
* @since 1.19
*/
public function getDescription() {
- global $wgLogHeaders;
+ $logHeaders = MediaWikiServices::getInstance()->getMainConfig()->get( 'LogHeaders' );
// BC
- $key = $wgLogHeaders[$this->type] ?? 'log-description-' . $this->type;
+ $key = $logHeaders[$this->type] ?? 'log-description-' . $this->type;
return wfMessage( $key );
}
@@ -469,10 +468,10 @@ class LogPage {
* @since 1.19
*/
public function getRestriction() {
- global $wgLogRestrictions;
+ $logRestrictions = MediaWikiServices::getInstance()->getMainConfig()->get( 'LogRestrictions' );
// The empty string fallback will
// always return true in permission check
- return $wgLogRestrictions[$this->type] ?? '';
+ return $logRestrictions[$this->type] ?? '';
}
/**
diff --git a/includes/logging/ManualLogEntry.php b/includes/logging/ManualLogEntry.php
index dade9e85ddf0..e938d95e0c10 100644
--- a/includes/logging/ManualLogEntry.php
+++ b/includes/logging/ManualLogEntry.php
@@ -25,6 +25,7 @@
use MediaWiki\ChangeTags\Taggable;
use MediaWiki\Linker\LinkTarget;
+use MediaWiki\MediaWikiServices;
use MediaWiki\Page\PageReference;
use MediaWiki\User\UserIdentity;
use Wikimedia\Assert\Assert;
@@ -285,7 +286,7 @@ class ManualLogEntry extends LogEntryBase implements Taggable {
$this->timestamp = wfTimestampNow();
}
- $actorId = \MediaWiki\MediaWikiServices::getInstance()->getActorStore()
+ $actorId = MediaWikiServices::getInstance()->getActorStore()
->acquireActorId( $this->getPerformerIdentity(), $dbw );
// Trim spaces on user supplied text
diff --git a/includes/logging/RightsLogFormatter.php b/includes/logging/RightsLogFormatter.php
index 914593814621..5bb5c7839f52 100644
--- a/includes/logging/RightsLogFormatter.php
+++ b/includes/logging/RightsLogFormatter.php
@@ -32,12 +32,13 @@ use MediaWiki\MediaWikiServices;
*/
class RightsLogFormatter extends LogFormatter {
protected function makePageLink( Title $title = null, $parameters = [], $html = null ) {
- global $wgUserrightsInterwikiDelimiter;
+ $userrightsInterwikiDelimiter = MediaWikiServices::getInstance()
+ ->getMainConfig()->get( 'UserrightsInterwikiDelimiter' );
if ( !$this->plaintext ) {
$text = MediaWikiServices::getInstance()->getContentLanguage()->
ucfirst( $title->getDBkey() );
- $parts = explode( $wgUserrightsInterwikiDelimiter, $text, 2 );
+ $parts = explode( $userrightsInterwikiDelimiter, $text, 2 );
if ( count( $parts ) === 2 ) {
// @phan-suppress-next-line SecurityCheck-DoubleEscaped
@@ -46,7 +47,7 @@ class RightsLogFormatter extends LogFormatter {
$parts[0],
htmlspecialchars(
strtr( $parts[0], '_', ' ' ) .
- $wgUserrightsInterwikiDelimiter .
+ $userrightsInterwikiDelimiter .
$parts[1]
)
);
diff --git a/includes/mail/UserMailer.php b/includes/mail/UserMailer.php
index f55ccf2d5ff7..555d1e2c2e06 100644
--- a/includes/mail/UserMailer.php
+++ b/includes/mail/UserMailer.php
@@ -1,4 +1,5 @@
<?php
+
/**
* Classes used to send e-mails
*
@@ -24,6 +25,8 @@
* @author Luke Welling lwelling@wikimedia.org
*/
+use MediaWiki\MediaWikiServices;
+
/**
* Collection of static functions for sending mail
*/
@@ -80,14 +83,14 @@ class UserMailer {
* @return string
*/
private static function makeMsgId() {
- global $wgSMTP, $wgServer;
-
+ $smtp = MediaWikiServices::getInstance()->getMainConfig()->get( 'SMTP' );
+ $server = MediaWikiServices::getInstance()->getMainConfig()->get( 'Server' );
$domainId = WikiMap::getCurrentWikiDbDomain()->getId();
$msgid = uniqid( $domainId . ".", true /** for cygwin */ );
- if ( is_array( $wgSMTP ) && isset( $wgSMTP['IDHost'] ) && $wgSMTP['IDHost'] ) {
- $domain = $wgSMTP['IDHost'];
+ if ( is_array( $smtp ) && isset( $smtp['IDHost'] ) && $smtp['IDHost'] ) {
+ $domain = $smtp['IDHost'];
} else {
- $url = wfParseUrl( $wgServer );
+ $url = wfParseUrl( $server );
$domain = $url['host'];
}
return "<$msgid@$domain>";
@@ -113,7 +116,7 @@ class UserMailer {
* @return Status
*/
public static function send( $to, $from, $subject, $body, $options = [] ) {
- global $wgAllowHTMLEmail;
+ $allowHTMLEmail = MediaWikiServices::getInstance()->getMainConfig()->get( 'AllowHTMLEmail' );
if ( !isset( $options['contentType'] ) ) {
$options['contentType'] = 'text/plain; charset=UTF-8';
@@ -146,7 +149,7 @@ class UserMailer {
return Status::newFatal( 'user-mail-no-body' );
}
- if ( !$wgAllowHTMLEmail && is_array( $body ) ) {
+ if ( !$allowHTMLEmail && is_array( $body ) ) {
// HTML not wanted. Dump it.
$body = $body['text'];
}
@@ -242,7 +245,10 @@ class UserMailer {
$body,
$options = []
) {
- global $wgSMTP, $wgEnotifMaxRecips, $wgAdditionalMailParams;
+ $mainConfig = MediaWikiServices::getInstance()->getMainConfig();
+ $smtp = $mainConfig->get( 'SMTP' );
+ $enotifMaxRecips = $mainConfig->get( 'EnotifMaxRecips' );
+ $additionalMailParams = $mainConfig->get( 'AdditionalMailParams' );
$mime = null;
$replyto = $options['replyTo'] ?? null;
@@ -290,7 +296,7 @@ class UserMailer {
$headers['From'] = $from->toString();
$returnPath = $from->address;
- $extraParams = $wgAdditionalMailParams;
+ $extraParams = $additionalMailParams;
// Hook to generate custom VERP address for 'Return-Path'
Hooks::runner()->onUserMailerChangeReturnPath( $to, $returnPath );
@@ -376,7 +382,7 @@ class UserMailer {
return Status::newFatal( 'php-mail-error', $ret );
}
- if ( is_array( $wgSMTP ) ) {
+ if ( is_array( $smtp ) ) {
// Check if pear/mail is already loaded (via composer)
if ( !self::isMailUsable() ) {
throw new MWException( 'PEAR mail package is not installed' );
@@ -387,7 +393,7 @@ class UserMailer {
Wikimedia\suppressWarnings();
// Create the mail object using the Mail::factory method
- $mail_object = Mail::factory( 'smtp', $wgSMTP );
+ $mail_object = Mail::factory( 'smtp', $smtp );
if ( PEAR::isError( $mail_object ) ) {
wfDebug( "PEAR::Mail factory failed: " . $mail_object->getMessage() );
Wikimedia\restoreWarnings();
@@ -406,7 +412,7 @@ class UserMailer {
// Split jobs since SMTP servers tends to limit the maximum
// number of possible recipients.
- $chunks = array_chunk( $recips, $wgEnotifMaxRecips );
+ $chunks = array_chunk( $recips, $enotifMaxRecips );
foreach ( $chunks as $chunk ) {
$status = self::sendWithPear( $mail_object, $chunk, $headers, $body );
// FIXME : some chunks might be sent while others are not!
diff --git a/includes/media/BitmapHandler.php b/includes/media/BitmapHandler.php
index 634e405103d5..6b8aced241db 100644
--- a/includes/media/BitmapHandler.php
+++ b/includes/media/BitmapHandler.php
@@ -21,6 +21,7 @@
* @ingroup Media
*/
+use MediaWiki\MediaWikiServices;
use MediaWiki\Shell\Shell;
/**
@@ -41,16 +42,18 @@ class BitmapHandler extends TransformationalImageHandler {
* @return string|callable One of client, im, custom, gd, imext or an array( object, method )
*/
protected function getScalerType( $dstPath, $checkDstPath = true ) {
- global $wgUseImageResize, $wgUseImageMagick, $wgCustomConvertCommand;
-
+ $mainConfig = MediaWikiServices::getInstance()->getMainConfig();
+ $useImageResize = $mainConfig->get( 'UseImageResize' );
+ $useImageMagick = $mainConfig->get( 'UseImageMagick' );
+ $customConvertCommand = $mainConfig->get( 'CustomConvertCommand' );
if ( !$dstPath && $checkDstPath ) {
# No output path available, client side scaling only
$scaler = 'client';
- } elseif ( !$wgUseImageResize ) {
+ } elseif ( !$useImageResize ) {
$scaler = 'client';
- } elseif ( $wgUseImageMagick ) {
+ } elseif ( $useImageMagick ) {
$scaler = 'im';
- } elseif ( $wgCustomConvertCommand ) {
+ } elseif ( $customConvertCommand ) {
$scaler = 'custom';
} elseif ( function_exists( 'imagecreatetruecolor' ) ) {
$scaler = 'gd';
@@ -109,14 +112,14 @@ class BitmapHandler extends TransformationalImageHandler {
* @return bool
*/
public function normaliseParams( $image, &$params ) {
- global $wgMaxInterlacingAreas;
+ $maxInterlacingAreas = MediaWikiServices::getInstance()->getMainConfig()->get( 'MaxInterlacingAreas' );
if ( !parent::normaliseParams( $image, $params ) ) {
return false;
}
$mimeType = $image->getMimeType();
$interlace = isset( $params['interlace'] ) && $params['interlace']
- && isset( $wgMaxInterlacingAreas[$mimeType] )
- && $this->getImageArea( $image ) <= $wgMaxInterlacingAreas[$mimeType];
+ && isset( $maxInterlacingAreas[$mimeType] )
+ && $this->getImageArea( $image ) <= $maxInterlacingAreas[$mimeType];
$params['interlace'] = $interlace;
return true;
}
@@ -151,10 +154,14 @@ class BitmapHandler extends TransformationalImageHandler {
*/
protected function transformImageMagick( $image, $params ) {
# use ImageMagick
- global $wgSharpenReductionThreshold, $wgSharpenParameter, $wgMaxAnimatedGifArea,
- $wgImageMagickTempDir, $wgImageMagickConvertCommand, $wgJpegPixelFormat,
- $wgJpegQuality;
-
+ $mainConfig = MediaWikiServices::getInstance()->getMainConfig();
+ $sharpenReductionThreshold = $mainConfig->get( 'SharpenReductionThreshold' );
+ $sharpenParameter = $mainConfig->get( 'SharpenParameter' );
+ $maxAnimatedGifArea = $mainConfig->get( 'MaxAnimatedGifArea' );
+ $imageMagickTempDir = $mainConfig->get( 'ImageMagickTempDir' );
+ $imageMagickConvertCommand = $mainConfig->get( 'ImageMagickConvertCommand' );
+ $jpegPixelFormat = $mainConfig->get( 'JpegPixelFormat' );
+ $jpegQuality = $mainConfig->get( 'JpegQuality' );
$quality = [];
$sharpen = [];
$scene = false;
@@ -165,23 +172,23 @@ class BitmapHandler extends TransformationalImageHandler {
if ( $params['mimeType'] == 'image/jpeg' ) {
$qualityVal = isset( $params['quality'] ) ? (string)$params['quality'] : null;
- $quality = [ '-quality', $qualityVal ?: (string)$wgJpegQuality ]; // 80% by default
+ $quality = [ '-quality', $qualityVal ?: (string)$jpegQuality ]; // 80% by default
if ( $params['interlace'] ) {
$animation_post = [ '-interlace', 'JPEG' ];
}
# Sharpening, see T8193
if ( ( $params['physicalWidth'] + $params['physicalHeight'] )
/ ( $params['srcWidth'] + $params['srcHeight'] )
- < $wgSharpenReductionThreshold
+ < $sharpenReductionThreshold
) {
- $sharpen = [ '-sharpen', $wgSharpenParameter ];
+ $sharpen = [ '-sharpen', $sharpenParameter ];
}
// JPEG decoder hint to reduce memory, available since IM 6.5.6-2
$decoderHint = [ '-define', "jpeg:size={$params['physicalDimensions']}" ];
- if ( $wgJpegPixelFormat ) {
- $factors = $this->imageMagickSubsampling( $wgJpegPixelFormat );
+ if ( $jpegPixelFormat ) {
+ $factors = $this->imageMagickSubsampling( $jpegPixelFormat );
$subsampling = [ '-sampling-factor', implode( ',', $factors ) ];
}
} elseif ( $params['mimeType'] == 'image/png' ) {
@@ -192,7 +199,7 @@ class BitmapHandler extends TransformationalImageHandler {
} elseif ( $params['mimeType'] == 'image/webp' ) {
$quality = [ '-quality', '95' ]; // zlib 9, adaptive filtering
} elseif ( $params['mimeType'] == 'image/gif' ) {
- if ( $this->getImageArea( $image ) > $wgMaxAnimatedGifArea ) {
+ if ( $this->getImageArea( $image ) > $maxAnimatedGifArea ) {
// Extract initial frame only; we're so big it'll
// be a total drag. :P
$scene = 0;
@@ -226,15 +233,15 @@ class BitmapHandler extends TransformationalImageHandler {
// Use one thread only, to avoid deadlock bugs on OOM
$env = [ 'OMP_NUM_THREADS' => 1 ];
- if ( strval( $wgImageMagickTempDir ) !== '' ) {
- $env['MAGICK_TMPDIR'] = $wgImageMagickTempDir;
+ if ( strval( $imageMagickTempDir ) !== '' ) {
+ $env['MAGICK_TMPDIR'] = $imageMagickTempDir;
}
$rotation = isset( $params['disableRotation'] ) ? 0 : $this->getRotation( $image );
list( $width, $height ) = $this->extractPreRotationDimensions( $params, $rotation );
$cmd = Shell::escape( ...array_merge(
- [ $wgImageMagickConvertCommand ],
+ [ $imageMagickConvertCommand ],
$quality,
// Specify white background color, will be used for transparent images
// in Internet Explorer/Windows instead of default black.
@@ -281,9 +288,12 @@ class BitmapHandler extends TransformationalImageHandler {
* @return MediaTransformError|false Error object if error occurred, false (=no error) otherwise
*/
protected function transformImageMagickExt( $image, $params ) {
- global $wgSharpenReductionThreshold, $wgSharpenParameter, $wgMaxAnimatedGifArea,
- $wgJpegPixelFormat, $wgJpegQuality;
-
+ $mainConfig = MediaWikiServices::getInstance()->getMainConfig();
+ $sharpenReductionThreshold = $mainConfig->get( 'SharpenReductionThreshold' );
+ $sharpenParameter = $mainConfig->get( 'SharpenParameter' );
+ $maxAnimatedGifArea = $mainConfig->get( 'MaxAnimatedGifArea' );
+ $jpegPixelFormat = $mainConfig->get( 'JpegPixelFormat' );
+ $jpegQuality = $mainConfig->get( 'JpegQuality' );
try {
$im = new Imagick();
$im->readImage( $params['srcPath'] );
@@ -292,19 +302,19 @@ class BitmapHandler extends TransformationalImageHandler {
// Sharpening, see T8193
if ( ( $params['physicalWidth'] + $params['physicalHeight'] )
/ ( $params['srcWidth'] + $params['srcHeight'] )
- < $wgSharpenReductionThreshold
+ < $sharpenReductionThreshold
) {
// Hack, since $wgSharpenParameter is written specifically for the command line convert
- list( $radius, $sigma ) = explode( 'x', $wgSharpenParameter );
+ list( $radius, $sigma ) = explode( 'x', $sharpenParameter );
$im->sharpenImage( $radius, $sigma );
}
$qualityVal = isset( $params['quality'] ) ? (string)$params['quality'] : null;
- $im->setCompressionQuality( $qualityVal ?: $wgJpegQuality );
+ $im->setCompressionQuality( $qualityVal ?: $jpegQuality );
if ( $params['interlace'] ) {
$im->setInterlaceScheme( Imagick::INTERLACE_JPEG );
}
- if ( $wgJpegPixelFormat ) {
- $factors = $this->imageMagickSubsampling( $wgJpegPixelFormat );
+ if ( $jpegPixelFormat ) {
+ $factors = $this->imageMagickSubsampling( $jpegPixelFormat );
$im->setSamplingFactors( $factors );
}
} elseif ( $params['mimeType'] == 'image/png' ) {
@@ -313,7 +323,7 @@ class BitmapHandler extends TransformationalImageHandler {
$im->setInterlaceScheme( Imagick::INTERLACE_PNG );
}
} elseif ( $params['mimeType'] == 'image/gif' ) {
- if ( $this->getImageArea( $image ) > $wgMaxAnimatedGifArea ) {
+ if ( $this->getImageArea( $image ) > $maxAnimatedGifArea ) {
// Extract initial frame only; we're so big it'll
// be a total drag. :P
$im->setImageScene( 0 );
@@ -372,12 +382,12 @@ class BitmapHandler extends TransformationalImageHandler {
*/
protected function transformCustom( $image, $params ) {
# Use a custom convert command
- global $wgCustomConvertCommand;
+ $customConvertCommand = MediaWikiServices::getInstance()->getMainConfig()->get( 'CustomConvertCommand' );
# Variables: %s %d %w %h
$src = Shell::escape( $params['srcPath'] );
$dst = Shell::escape( $params['dstPath'] );
- $cmd = $wgCustomConvertCommand;
+ $cmd = $customConvertCommand;
$cmd = str_replace( '%s', $src, str_replace( '%d', $dst, $cmd ) ); # Filenames
$cmd = str_replace( '%h', Shell::escape( $params['physicalHeight'] ),
str_replace( '%w', Shell::escape( $params['physicalWidth'] ), $cmd ) ); # Size
@@ -506,10 +516,10 @@ class BitmapHandler extends TransformationalImageHandler {
* or null to use default quality.
*/
public static function imageJpegWrapper( $dst_image, $thumbPath, $quality = null ) {
- global $wgJpegQuality;
+ $jpegQuality = MediaWikiServices::getInstance()->getMainConfig()->get( 'JpegQuality' );
if ( $quality === null ) {
- $quality = $wgJpegQuality;
+ $quality = $jpegQuality;
}
imageinterlace( $dst_image );
@@ -547,14 +557,14 @@ class BitmapHandler extends TransformationalImageHandler {
* @return bool Whether auto rotation is enabled
*/
public function autoRotateEnabled() {
- global $wgEnableAutoRotation;
+ $enableAutoRotation = MediaWikiServices::getInstance()->getMainConfig()->get( 'EnableAutoRotation' );
- if ( $wgEnableAutoRotation === null ) {
+ if ( $enableAutoRotation === null ) {
// Only enable auto-rotation when we actually can
return $this->canRotate();
}
- return $wgEnableAutoRotation;
+ return $enableAutoRotation;
}
/**
@@ -566,7 +576,8 @@ class BitmapHandler extends TransformationalImageHandler {
* @return bool|MediaTransformError
*/
public function rotate( $file, $params ) {
- global $wgImageMagickConvertCommand;
+ $imageMagickConvertCommand = MediaWikiServices::getInstance()
+ ->getMainConfig()->get( 'ImageMagickConvertCommand' );
$rotation = ( $params['rotation'] + $this->getRotation( $file ) ) % 360;
$scene = false;
@@ -574,7 +585,7 @@ class BitmapHandler extends TransformationalImageHandler {
$scaler = $this->getScalerType( null, false );
switch ( $scaler ) {
case 'im':
- $cmd = Shell::escape( $wgImageMagickConvertCommand ) . " " .
+ $cmd = Shell::escape( $imageMagickConvertCommand ) . " " .
Shell::escape( $this->escapeMagickInput( $params['srcPath'], $scene ) ) .
" -rotate " . Shell::escape( "-$rotation" ) . " " .
Shell::escape( $this->escapeMagickOutput( $params['dstPath'] ) );
diff --git a/includes/media/BitmapMetadataHandler.php b/includes/media/BitmapMetadataHandler.php
index 7957fec3ff80..d73407e9fde5 100644
--- a/includes/media/BitmapMetadataHandler.php
+++ b/includes/media/BitmapMetadataHandler.php
@@ -22,6 +22,7 @@
*/
use MediaWiki\Logger\LoggerFactory;
+use MediaWiki\MediaWikiServices;
use Wikimedia\XMPReader\Reader as XMPReader;
/**
@@ -91,8 +92,8 @@ class BitmapMetadataHandler {
* @param string $byteOrder
*/
public function getExif( $filename, $byteOrder ) {
- global $wgShowEXIF;
- if ( file_exists( $filename ) && $wgShowEXIF ) {
+ $showEXIF = MediaWikiServices::getInstance()->getMainConfig()->get( 'ShowEXIF' );
+ if ( file_exists( $filename ) && $showEXIF ) {
$exif = new Exif( $filename, $byteOrder );
$data = $exif->getFilteredData();
if ( $data ) {
diff --git a/includes/media/DjVuHandler.php b/includes/media/DjVuHandler.php
index ede31586073f..38cf7c390666 100644
--- a/includes/media/DjVuHandler.php
+++ b/includes/media/DjVuHandler.php
@@ -20,6 +20,7 @@
* @file
* @ingroup Media
*/
+
use MediaWiki\MediaWikiServices;
use MediaWiki\Shell\Shell;
@@ -41,8 +42,9 @@ class DjVuHandler extends ImageHandler {
* @return bool
*/
public function isEnabled() {
- global $wgDjvuRenderer, $wgDjvuDump;
- if ( !$wgDjvuRenderer || !$wgDjvuDump ) {
+ $djvuRenderer = MediaWikiServices::getInstance()->getMainConfig()->get( 'DjvuRenderer' );
+ $djvuDump = MediaWikiServices::getInstance()->getMainConfig()->get( 'DjvuDump' );
+ if ( !$djvuRenderer || !$djvuDump ) {
wfDebug( "DjVu is disabled, please set \$wgDjvuRenderer and \$wgDjvuDump" );
return false;
@@ -146,8 +148,8 @@ class DjVuHandler extends ImageHandler {
* @return MediaTransformError|ThumbnailImage|TransformParameterError
*/
public function doTransform( $image, $dstPath, $dstUrl, $params, $flags = 0 ) {
- global $wgDjvuRenderer, $wgDjvuPostProcessor;
-
+ $djvuRenderer = MediaWikiServices::getInstance()->getMainConfig()->get( 'DjvuRenderer' );
+ $djvuPostProcessor = MediaWikiServices::getInstance()->getMainConfig()->get( 'DjvuPostProcessor' );
if ( !$this->normaliseParams( $image, $params ) ) {
return new TransformParameterError( $params );
}
@@ -204,13 +206,13 @@ class DjVuHandler extends ImageHandler {
# Use a subshell (brackets) to aggregate stderr from both pipeline commands
# before redirecting it to the overall stdout. This works in both Linux and Windows XP.
$cmd = '(' . Shell::escape(
- $wgDjvuRenderer,
+ $djvuRenderer,
"-format=ppm",
"-page={$page}",
"-size={$params['physicalWidth']}x{$params['physicalHeight']}",
$srcPath );
- if ( $wgDjvuPostProcessor ) {
- $cmd .= " | {$wgDjvuPostProcessor}";
+ if ( $djvuPostProcessor ) {
+ $cmd .= " | {$djvuPostProcessor}";
}
$cmd .= ' > ' . Shell::escape( $dstPath ) . ') 2>&1';
wfDebug( __METHOD__ . ": $cmd" );
@@ -301,14 +303,14 @@ class DjVuHandler extends ImageHandler {
}
public function getThumbType( $ext, $mime, $params = null ) {
- global $wgDjvuOutputExtension;
+ $djvuOutputExtension = MediaWikiServices::getInstance()->getMainConfig()->get( 'DjvuOutputExtension' );
static $mime;
if ( !isset( $mime ) ) {
- $magic = MediaWiki\MediaWikiServices::getInstance()->getMimeAnalyzer();
- $mime = $magic->getMimeTypeFromExtensionOrNull( $wgDjvuOutputExtension );
+ $magic = MediaWikiServices::getInstance()->getMimeAnalyzer();
+ $mime = $magic->getMimeTypeFromExtensionOrNull( $djvuOutputExtension );
}
- return [ $wgDjvuOutputExtension, $mime ];
+ return [ $djvuOutputExtension, $mime ];
}
public function getSizeAndMetadata( $state, $path ) {
diff --git a/includes/media/DjVuImage.php b/includes/media/DjVuImage.php
index 350115b9524c..de842fba3e7a 100644
--- a/includes/media/DjVuImage.php
+++ b/includes/media/DjVuImage.php
@@ -24,6 +24,7 @@
* @ingroup Media
*/
+use MediaWiki\MediaWikiServices;
use MediaWiki\Shell\Shell;
/**
@@ -249,24 +250,24 @@ class DjVuImage {
* @return array|null|false
*/
public function retrieveMetaData() {
- global $wgDjvuDump, $wgDjvuTxt;
-
+ $djvuDump = MediaWikiServices::getInstance()->getMainConfig()->get( 'DjvuDump' );
+ $djvuTxt = MediaWikiServices::getInstance()->getMainConfig()->get( 'DjvuTxt' );
if ( !$this->isValid() ) {
return false;
}
- if ( isset( $wgDjvuDump ) ) {
+ if ( isset( $djvuDump ) ) {
# djvudump is faster than djvutoxml (now abandoned) as of version 3.5
# https://sourceforge.net/p/djvu/bugs/71/
- $cmd = Shell::escape( $wgDjvuDump ) . ' ' . Shell::escape( $this->mFilename );
+ $cmd = Shell::escape( $djvuDump ) . ' ' . Shell::escape( $this->mFilename );
$dump = wfShellExec( $cmd );
$json = [ 'data' => $this->convertDumpToJSON( $dump ) ];
} else {
$json = null;
}
# Text layer
- if ( isset( $wgDjvuTxt ) ) {
- $cmd = Shell::escape( $wgDjvuTxt ) . ' --detail=page ' . Shell::escape( $this->mFilename );
+ if ( isset( $djvuTxt ) ) {
+ $cmd = Shell::escape( $djvuTxt ) . ' --detail=page ' . Shell::escape( $this->mFilename );
wfDebug( __METHOD__ . ": $cmd" );
$retval = '';
$txt = wfShellExec( $cmd, $retval, [], [ 'memory' => self::DJVUTXT_MEMORY_LIMIT ] );
diff --git a/includes/media/ExifBitmapHandler.php b/includes/media/ExifBitmapHandler.php
index 31a5099cb5d6..d55fd8864fd4 100644
--- a/includes/media/ExifBitmapHandler.php
+++ b/includes/media/ExifBitmapHandler.php
@@ -1,4 +1,5 @@
<?php
+
/**
* Handler for bitmap images with exif metadata.
*
@@ -21,6 +22,8 @@
* @ingroup Media
*/
+use MediaWiki\MediaWikiServices;
+
/**
* Stuff specific to JPEG and (built-in) TIFF handler.
* All metadata related, since both JPEG and TIFF support Exif.
@@ -83,8 +86,8 @@ class ExifBitmapHandler extends BitmapHandler {
* @return bool|int
*/
public function isFileMetadataValid( $image ) {
- global $wgShowEXIF;
- if ( !$wgShowEXIF ) {
+ $showEXIF = MediaWikiServices::getInstance()->getMainConfig()->get( 'ShowEXIF' );
+ if ( !$showEXIF ) {
# Metadata disabled and so an empty field is expected
return self::METADATA_GOOD;
}
diff --git a/includes/media/GIFHandler.php b/includes/media/GIFHandler.php
index d5189886378a..871195d38bb4 100644
--- a/includes/media/GIFHandler.php
+++ b/includes/media/GIFHandler.php
@@ -21,6 +21,7 @@
* @ingroup Media
*/
+use MediaWiki\MediaWikiServices;
use Wikimedia\RequestTimeout\TimeoutException;
/**
@@ -120,9 +121,9 @@ class GIFHandler extends BitmapHandler {
* @return bool
*/
public function canAnimateThumbnail( $file ) {
- global $wgMaxAnimatedGifArea;
+ $maxAnimatedGifArea = MediaWikiServices::getInstance()->getMainConfig()->get( 'MaxAnimatedGifArea' );
- return $this->getImageArea( $file ) <= $wgMaxAnimatedGifArea;
+ return $this->getImageArea( $file ) <= $maxAnimatedGifArea;
}
public function getMetadataType( $image ) {
diff --git a/includes/media/JpegHandler.php b/includes/media/JpegHandler.php
index c03505ea23ef..480e6735c173 100644
--- a/includes/media/JpegHandler.php
+++ b/includes/media/JpegHandler.php
@@ -21,6 +21,7 @@
* @ingroup Media
*/
+use MediaWiki\MediaWikiServices;
use MediaWiki\Shell\Shell;
/**
@@ -141,12 +142,12 @@ class JpegHandler extends ExifBitmapHandler {
* @return bool|MediaTransformError
*/
public function rotate( $file, $params ) {
- global $wgJpegTran;
+ $jpegTran = MediaWikiServices::getInstance()->getMainConfig()->get( 'JpegTran' );
$rotation = ( $params['rotation'] + $this->getRotation( $file ) ) % 360;
- if ( $wgJpegTran && is_executable( $wgJpegTran ) ) {
- $command = Shell::command( $wgJpegTran,
+ if ( $jpegTran && is_executable( $jpegTran ) ) {
+ $command = Shell::command( $jpegTran,
'-rotate',
$rotation,
'-outfile',
@@ -188,7 +189,8 @@ class JpegHandler extends ExifBitmapHandler {
* @inheritDoc
*/
protected function transformImageMagick( $image, $params ) {
- global $wgUseTinyRGBForJPGThumbnails;
+ $useTinyRGBForJPGThumbnails = MediaWikiServices::getInstance()
+ ->getMainConfig()->get( 'UseTinyRGBForJPGThumbnails' );
$ret = parent::transformImageMagick( $image, $params );
@@ -196,7 +198,7 @@ class JpegHandler extends ExifBitmapHandler {
return $ret;
}
- if ( $wgUseTinyRGBForJPGThumbnails ) {
+ if ( $useTinyRGBForJPGThumbnails ) {
// T100976 If the profile embedded in the JPG is sRGB, swap it for the smaller
// (and free) TinyRGB
@@ -244,14 +246,14 @@ class JpegHandler extends ExifBitmapHandler {
public function swapICCProfile( $filepath, array $colorSpaces,
array $oldProfileStrings, $profileFilepath
) {
- global $wgExiftool;
+ $exiftool = MediaWikiServices::getInstance()->getMainConfig()->get( 'Exiftool' );
- if ( !$wgExiftool || !is_executable( $wgExiftool ) ) {
+ if ( !$exiftool || !is_executable( $exiftool ) ) {
return false;
}
$result = Shell::command(
- $wgExiftool,
+ $exiftool,
'-EXIF:ColorSpace',
'-ICC_Profile:ProfileDescription',
'-S',
@@ -282,7 +284,7 @@ class JpegHandler extends ExifBitmapHandler {
return false;
}
- $command = Shell::command( $wgExiftool,
+ $command = Shell::command( $exiftool,
'-overwrite_original',
'-icc_profile<=' . $profileFilepath,
$filepath
diff --git a/includes/media/MediaHandler.php b/includes/media/MediaHandler.php
index a1b4e1a91b0f..6610f92ee36f 100644
--- a/includes/media/MediaHandler.php
+++ b/includes/media/MediaHandler.php
@@ -18,6 +18,7 @@
* @file
* @ingroup Media
*/
+
use MediaWiki\MediaWikiServices;
/**
@@ -472,7 +473,7 @@ abstract class MediaHandler {
* @return array Thumbnail extension and MIME type
*/
public function getThumbType( $ext, $mime, $params = null ) {
- $magic = MediaWiki\MediaWikiServices::getInstance()->getMimeAnalyzer();
+ $magic = MediaWikiServices::getInstance()->getMimeAnalyzer();
if ( !$ext || $magic->isMatchingExtension( $ext, $mime ) === false ) {
// The extension is not valid for this MIME type and we do
// recognize the MIME type
diff --git a/includes/media/MediaTransformOutput.php b/includes/media/MediaTransformOutput.php
index 32422bdd8361..e720c003af64 100644
--- a/includes/media/MediaTransformOutput.php
+++ b/includes/media/MediaTransformOutput.php
@@ -1,4 +1,5 @@
<?php
+
/**
* Base class for the output of file transformation methods.
*
@@ -21,6 +22,8 @@
* @ingroup Media
*/
+use MediaWiki\MediaWikiServices;
+
/**
* Base class for the output of MediaHandler::doTransform() and File::transform().
*
@@ -242,8 +245,9 @@ abstract class MediaTransformOutput {
if ( $linkAttribs ) {
return Xml::tags( 'a', $linkAttribs, $contents );
} else {
- global $wgParserEnableLegacyMediaDOM;
- if ( $wgParserEnableLegacyMediaDOM ) {
+ $parserEnableLegacyMediaDOM = MediaWikiServices::getInstance()
+ ->getMainConfig()->get( 'ParserEnableLegacyMediaDOM' );
+ if ( $parserEnableLegacyMediaDOM ) {
return $contents;
} else {
return Xml::tags( 'span', null, $contents );
@@ -277,8 +281,9 @@ abstract class MediaTransformOutput {
'href' => $this->file->getTitle()->getLocalURL( $query ),
];
- global $wgParserEnableLegacyMediaDOM;
- if ( $wgParserEnableLegacyMediaDOM ) {
+ $parserEnableLegacyMediaDOM = MediaWikiServices::getInstance()
+ ->getMainConfig()->get( 'ParserEnableLegacyMediaDOM' );
+ if ( $parserEnableLegacyMediaDOM ) {
$attribs['class'] = 'image';
}
diff --git a/includes/media/SVGReader.php b/includes/media/SVGReader.php
index e42cb446ab05..264ec3e3e9c2 100644
--- a/includes/media/SVGReader.php
+++ b/includes/media/SVGReader.php
@@ -1,4 +1,5 @@
<?php
+
/**
* Extraction of SVG image metadata.
*
@@ -25,6 +26,8 @@
* @license GPL-2.0-or-later
*/
+use MediaWiki\MediaWikiServices;
+
/**
* @ingroup Media
*/
@@ -52,7 +55,7 @@ class SVGReader {
* @throws MWException|Exception
*/
public function __construct( $source ) {
- global $wgSVGMetadataCutoff;
+ $svgMetadataCutoff = MediaWikiServices::getInstance()->getMainConfig()->get( 'SVGMetadataCutoff' );
$this->reader = new XMLReader();
// Don't use $file->getSize() since file object passed to SVGHandler::getMetadata is bogus.
@@ -61,9 +64,9 @@ class SVGReader {
throw new MWException( "Error getting filesize of SVG." );
}
- if ( $size > $wgSVGMetadataCutoff ) {
- $this->debug( "SVG is $size bytes, which is bigger than $wgSVGMetadataCutoff. Truncating." );
- $contents = file_get_contents( $source, false, null, 0, $wgSVGMetadataCutoff );
+ if ( $size > $svgMetadataCutoff ) {
+ $this->debug( "SVG is $size bytes, which is bigger than {$svgMetadataCutoff}. Truncating." );
+ $contents = file_get_contents( $source, false, null, 0, $svgMetadataCutoff );
if ( $contents === false ) {
throw new MWException( 'Error reading SVG file.' );
}
diff --git a/includes/media/SvgHandler.php b/includes/media/SvgHandler.php
index 51f7e4a1997a..e0469f065db6 100644
--- a/includes/media/SvgHandler.php
+++ b/includes/media/SvgHandler.php
@@ -45,8 +45,9 @@ class SvgHandler extends ImageHandler {
];
public function isEnabled() {
- global $wgSVGConverters, $wgSVGConverter;
- if ( !isset( $wgSVGConverters[$wgSVGConverter] ) ) {
+ $svgConverters = MediaWikiServices::getInstance()->getMainConfig()->get( 'SVGConverters' );
+ $svgConverter = MediaWikiServices::getInstance()->getMainConfig()->get( 'SVGConverter' );
+ if ( !isset( $svgConverters[$svgConverter] ) ) {
wfDebug( "\$wgSVGConverter is invalid, disabling SVG rendering." );
return false;
@@ -186,21 +187,21 @@ class SvgHandler extends ImageHandler {
* @return array Modified $params
*/
protected function normaliseParamsInternal( $image, $params ) {
- global $wgSVGMaxSize;
+ $svgMaxSize = MediaWikiServices::getInstance()->getMainConfig()->get( 'SVGMaxSize' );
# Don't make an image bigger than wgMaxSVGSize on the smaller side
if ( $params['physicalWidth'] <= $params['physicalHeight'] ) {
- if ( $params['physicalWidth'] > $wgSVGMaxSize ) {
+ if ( $params['physicalWidth'] > $svgMaxSize ) {
$srcWidth = $image->getWidth( $params['page'] );
$srcHeight = $image->getHeight( $params['page'] );
- $params['physicalWidth'] = $wgSVGMaxSize;
- $params['physicalHeight'] = File::scaleHeight( $srcWidth, $srcHeight, $wgSVGMaxSize );
+ $params['physicalWidth'] = $svgMaxSize;
+ $params['physicalHeight'] = File::scaleHeight( $srcWidth, $srcHeight, $svgMaxSize );
}
- } elseif ( $params['physicalHeight'] > $wgSVGMaxSize ) {
+ } elseif ( $params['physicalHeight'] > $svgMaxSize ) {
$srcWidth = $image->getWidth( $params['page'] );
$srcHeight = $image->getHeight( $params['page'] );
- $params['physicalWidth'] = File::scaleHeight( $srcHeight, $srcWidth, $wgSVGMaxSize );
- $params['physicalHeight'] = $wgSVGMaxSize;
+ $params['physicalWidth'] = File::scaleHeight( $srcHeight, $srcWidth, $svgMaxSize );
+ $params['physicalHeight'] = $svgMaxSize;
}
// To prevent the proliferation of thumbnails in languages not present in SVGs, unless
// explicitly forced by user.
@@ -310,13 +311,16 @@ class SvgHandler extends ImageHandler {
* @return bool|MediaTransformError
*/
public function rasterize( $srcPath, $dstPath, $width, $height, $lang = false ) {
- global $wgSVGConverters, $wgSVGConverter, $wgSVGConverterPath;
+ $mainConfig = MediaWikiServices::getInstance()->getMainConfig();
+ $svgConverters = $mainConfig->get( 'SVGConverters' );
+ $svgConverter = $mainConfig->get( 'SVGConverter' );
+ $svgConverterPath = $mainConfig->get( 'SVGConverterPath' );
$err = false;
$retval = '';
- if ( isset( $wgSVGConverters[$wgSVGConverter] ) ) {
- if ( is_array( $wgSVGConverters[$wgSVGConverter] ) ) {
+ if ( isset( $svgConverters[$svgConverter] ) ) {
+ if ( is_array( $svgConverters[$svgConverter] ) ) {
// This is a PHP callable
- $func = $wgSVGConverters[$wgSVGConverter][0];
+ $func = $svgConverters[$svgConverter][0];
if ( !is_callable( $func ) ) {
throw new MWException( "$func is not callable" );
}
@@ -325,19 +329,19 @@ class SvgHandler extends ImageHandler {
$width,
$height,
$lang,
- ...array_slice( $wgSVGConverters[$wgSVGConverter], 1 )
+ ...array_slice( $svgConverters[$svgConverter], 1 )
);
$retval = (bool)$err;
} else {
// External command
$cmd = str_replace(
[ '$path/', '$width', '$height', '$input', '$output' ],
- [ $wgSVGConverterPath ? Shell::escape( "$wgSVGConverterPath/" ) : "",
+ [ $svgConverterPath ? Shell::escape( "{$svgConverterPath}/" ) : "",
intval( $width ),
intval( $height ),
Shell::escape( $srcPath ),
Shell::escape( $dstPath ) ],
- $wgSVGConverters[$wgSVGConverter]
+ $svgConverters[$svgConverter]
);
$env = [];
diff --git a/includes/media/ThumbnailImage.php b/includes/media/ThumbnailImage.php
index d4cea4f08226..f01c6676949f 100644
--- a/includes/media/ThumbnailImage.php
+++ b/includes/media/ThumbnailImage.php
@@ -1,4 +1,5 @@
<?php
+
/**
* Base class for the output of file transformation methods.
*
@@ -21,6 +22,8 @@
* @ingroup Media
*/
+use MediaWiki\MediaWikiServices;
+
/**
* Media transform output for images
*
@@ -111,8 +114,12 @@ class ThumbnailImage extends MediaTransformOutput {
* @return string
*/
public function toHtml( $options = [] ) {
- global $wgPriorityHints, $wgPriorityHintsRatio, $wgElementTiming,
- $wgNativeImageLazyLoading, $wgParserEnableLegacyMediaDOM;
+ $mainConfig = MediaWikiServices::getInstance()->getMainConfig();
+ $priorityHints = $mainConfig->get( 'PriorityHints' );
+ $priorityHintsRatio = $mainConfig->get( 'PriorityHintsRatio' );
+ $elementTiming = $mainConfig->get( 'ElementTiming' );
+ $nativeImageLazyLoading = $mainConfig->get( 'NativeImageLazyLoading' );
+ $parserEnableLegacyMediaDOM = $mainConfig->get( 'ParserEnableLegacyMediaDOM' );
if ( func_num_args() == 2 ) {
throw new MWException( __METHOD__ . ' called in the old style' );
@@ -129,7 +136,7 @@ class ThumbnailImage extends MediaTransformOutput {
'alt' => $alt
];
- if ( !$wgParserEnableLegacyMediaDOM ) {
+ if ( !$parserEnableLegacyMediaDOM ) {
$attribs['resource'] = $options['resource'] ?? $descLinkAttribs['href'];
}
@@ -138,13 +145,13 @@ class ThumbnailImage extends MediaTransformOutput {
'decoding' => 'async',
];
- if ( $options['loading'] ?? $wgNativeImageLazyLoading ) {
+ if ( $options['loading'] ?? $nativeImageLazyLoading ) {
$attribs['loading'] = $options['loading'] ?? 'lazy';
}
$elementTimingName = 'thumbnail';
- if ( $wgPriorityHints
+ if ( $priorityHints
&& !self::$firstNonIconImageRendered
&& $this->width * $this->height > 100 * 100 ) {
self::$firstNonIconImageRendered = true;
@@ -152,7 +159,7 @@ class ThumbnailImage extends MediaTransformOutput {
// Generate a random number between 0.01 and 1.0, included
$random = rand( 1, 100 ) / 100.0;
- if ( $random <= $wgPriorityHintsRatio ) {
+ if ( $random <= $priorityHintsRatio ) {
$attribs['importance'] = 'high';
$elementTimingName = 'thumbnail-high';
} else {
@@ -161,7 +168,7 @@ class ThumbnailImage extends MediaTransformOutput {
}
}
- if ( $wgElementTiming ) {
+ if ( $elementTiming ) {
$attribs['elementtiming'] = $elementTimingName;
}
diff --git a/includes/media/TiffHandler.php b/includes/media/TiffHandler.php
index a495c6f83aac..21df979d98ca 100644
--- a/includes/media/TiffHandler.php
+++ b/includes/media/TiffHandler.php
@@ -21,6 +21,7 @@
* @ingroup Media
*/
+use MediaWiki\MediaWikiServices;
use Wikimedia\RequestTimeout\TimeoutException;
/**
@@ -46,9 +47,9 @@ class TiffHandler extends ExifBitmapHandler {
* @return bool
*/
public function canRender( $file ) {
- global $wgTiffThumbnailType;
+ $tiffThumbnailType = MediaWikiServices::getInstance()->getMainConfig()->get( 'TiffThumbnailType' );
- return (bool)$wgTiffThumbnailType
+ return (bool)$tiffThumbnailType
|| $file->getRepo() instanceof ForeignAPIRepo;
}
@@ -70,13 +71,13 @@ class TiffHandler extends ExifBitmapHandler {
* @return array
*/
public function getThumbType( $ext, $mime, $params = null ) {
- global $wgTiffThumbnailType;
+ $tiffThumbnailType = MediaWikiServices::getInstance()->getMainConfig()->get( 'TiffThumbnailType' );
- return $wgTiffThumbnailType;
+ return $tiffThumbnailType;
}
public function getSizeAndMetadata( $state, $filename ) {
- global $wgShowEXIF;
+ $showEXIF = MediaWikiServices::getInstance()->getMainConfig()->get( 'ShowEXIF' );
try {
$meta = BitmapMetadataHandler::Tiff( $filename );
@@ -89,7 +90,7 @@ class TiffHandler extends ExifBitmapHandler {
'height' => $meta['ImageLength'] ?? 0,
];
$info = $this->applyExifRotation( $info, $meta );
- if ( $wgShowEXIF ) {
+ if ( $showEXIF ) {
$meta['MEDIAWIKI_EXIF_VERSION'] = Exif::version();
$info['metadata'] = $meta;
}
diff --git a/includes/media/TransformationalImageHandler.php b/includes/media/TransformationalImageHandler.php
index 2551e03ba5e3..781293c5af7b 100644
--- a/includes/media/TransformationalImageHandler.php
+++ b/includes/media/TransformationalImageHandler.php
@@ -25,6 +25,7 @@
* @file
* @ingroup Media
*/
+
use MediaWiki\MediaWikiServices;
use MediaWiki\Shell\Shell;
@@ -174,8 +175,8 @@ abstract class TransformationalImageHandler extends ImageHandler {
}
if ( $image->isTransformedLocally() && !$this->isImageAreaOkForThumbnaling( $image, $params ) ) {
- global $wgMaxImageArea;
- return new TransformTooBigImageAreaError( $params, $wgMaxImageArea );
+ $maxImageArea = MediaWikiServices::getInstance()->getMainConfig()->get( 'MaxImageArea' );
+ return new TransformTooBigImageAreaError( $params, $maxImageArea );
}
if ( $flags & self::TRANSFORM_LATER ) {
@@ -525,9 +526,10 @@ abstract class TransformationalImageHandler extends ImageHandler {
$cache->makeGlobalKey( 'imagemagick-version' ),
$cache::TTL_HOUR,
static function () use ( $method ) {
- global $wgImageMagickConvertCommand;
+ $imageMagickConvertCommand = MediaWikiServices::getInstance()
+ ->getMainConfig()->get( 'ImageMagickConvertCommand' );
- $cmd = Shell::escape( $wgImageMagickConvertCommand ) . ' -version';
+ $cmd = Shell::escape( $imageMagickConvertCommand ) . ' -version';
wfDebug( $method . ": Running convert -version" );
$retval = '';
$return = wfShellExecWithStderr( $cmd, $retval );
@@ -608,7 +610,7 @@ abstract class TransformationalImageHandler extends ImageHandler {
* @since 1.25
*/
public function isImageAreaOkForThumbnaling( $file, &$params ) {
- global $wgMaxImageArea;
+ $maxImageArea = MediaWikiServices::getInstance()->getMainConfig()->get( 'MaxImageArea' );
# For historical reasons, hook starts with BitmapHandler
$checkImageAreaHookResult = null;
@@ -620,7 +622,7 @@ abstract class TransformationalImageHandler extends ImageHandler {
return (bool)$checkImageAreaHookResult;
}
- if ( $wgMaxImageArea === false ) {
+ if ( $maxImageArea === false ) {
// Checking is disabled, fine to thumbnail
return true;
}
@@ -628,7 +630,7 @@ abstract class TransformationalImageHandler extends ImageHandler {
$srcWidth = $file->getWidth( $params['page'] );
$srcHeight = $file->getHeight( $params['page'] );
- if ( $srcWidth * $srcHeight > $wgMaxImageArea
+ if ( $srcWidth * $srcHeight > $maxImageArea
&& !( $file->getMimeType() == 'image/jpeg'
&& $this->getScalerType( false, false ) == 'im' )
) {
diff --git a/includes/page/Article.php b/includes/page/Article.php
index af6a1eb47752..be91701f8671 100644
--- a/includes/page/Article.php
+++ b/includes/page/Article.php
@@ -425,7 +425,7 @@ class Article implements Page {
* page of the given title.
*/
public function view() {
- global $wgUseFileCache;
+ $useFileCache = MediaWikiServices::getInstance()->getMainConfig()->get( 'UseFileCache' );
# Get variables from query string
# As side effect this will load the revision and update the title
@@ -495,7 +495,7 @@ class Article implements Page {
# Try client and file cache
if ( $oldid === 0 && $this->mPage->checkTouched() ) {
# Try to stream the output from file cache
- if ( $wgUseFileCache && $this->tryFileCache() ) {
+ if ( $useFileCache && $this->tryFileCache() ) {
wfDebug( __METHOD__ . ": done file cache" );
# tell wgOut that output is taken care of
$outputPage->disable();
@@ -777,14 +777,14 @@ class Article implements Page {
OutputPage $outputPage,
array $textOptions
) {
- global $wgCdnMaxageStale;
+ $cdnMaxageStale = MediaWikiServices::getInstance()->getMainConfig()->get( 'CdnMaxageStale' );
$ok = $renderStatus->isOK();
$pOutput = $ok ? $renderStatus->getValue() : null;
// Cache stale ParserOutput object with a short expiry
if ( $ok && $renderStatus->hasMessage( 'view-pool-dirty-output' ) ) {
- $outputPage->setCdnMaxage( $wgCdnMaxageStale );
+ $outputPage->setCdnMaxage( $cdnMaxageStale );
$outputPage->setLastModified( $pOutput->getCacheTime() );
$staleReason = $renderStatus->hasMessage( 'view-pool-contention' )
? $this->getContext()->msg( 'view-pool-contention' )
@@ -906,8 +906,10 @@ class Article implements Page {
* @todo actions other than 'view'
*/
public function getRobotPolicy( $action, ParserOutput $pOutput = null ) {
- global $wgArticleRobotPolicies, $wgNamespaceRobotPolicies, $wgDefaultRobotPolicy;
-
+ $mainConfig = MediaWikiServices::getInstance()->getMainConfig();
+ $articleRobotPolicies = $mainConfig->get( 'ArticleRobotPolicies' );
+ $namespaceRobotPolicies = $mainConfig->get( 'NamespaceRobotPolicies' );
+ $defaultRobotPolicy = $mainConfig->get( 'DefaultRobotPolicy' );
$ns = $this->getTitle()->getNamespace();
# Don't index user and user talk pages for blocked users (T13443)
@@ -949,13 +951,13 @@ class Article implements Page {
}
# Otherwise, construct the policy based on the various config variables.
- $policy = self::formatRobotPolicy( $wgDefaultRobotPolicy );
+ $policy = self::formatRobotPolicy( $defaultRobotPolicy );
- if ( isset( $wgNamespaceRobotPolicies[$ns] ) ) {
+ if ( isset( $namespaceRobotPolicies[$ns] ) ) {
# Honour customised robot policies for this namespace
$policy = array_merge(
$policy,
- self::formatRobotPolicy( $wgNamespaceRobotPolicies[$ns] )
+ self::formatRobotPolicy( $namespaceRobotPolicies[$ns] )
);
}
if ( $this->getTitle()->canUseNoindex() && is_object( $pOutput ) && $pOutput->getIndexPolicy() ) {
@@ -967,11 +969,11 @@ class Article implements Page {
);
}
- if ( isset( $wgArticleRobotPolicies[$this->getTitle()->getPrefixedText()] ) ) {
+ if ( isset( $articleRobotPolicies[$this->getTitle()->getPrefixedText()] ) ) {
# (T16900) site config can override user-defined __INDEX__ or __NOINDEX__
$policy = array_merge(
$policy,
- self::formatRobotPolicy( $wgArticleRobotPolicies[$this->getTitle()->getPrefixedText()] )
+ self::formatRobotPolicy( $articleRobotPolicies[$this->getTitle()->getPrefixedText()] )
);
}
@@ -1015,7 +1017,7 @@ class Article implements Page {
* @return bool
*/
public function showRedirectedFromHeader() {
- global $wgRedirectSources;
+ $redirectSources = MediaWikiServices::getInstance()->getMainConfig()->get( 'RedirectSources' );
$context = $this->getContext();
$outputPage = $context->getOutput();
@@ -1065,7 +1067,7 @@ class Article implements Page {
} elseif ( $rdfrom ) {
// This is an externally redirected view, from some other wiki.
// If it was reported from a trusted site, supply a backlink.
- if ( $wgRedirectSources && preg_match( $wgRedirectSources, $rdfrom ) ) {
+ if ( $redirectSources && preg_match( $redirectSources, $rdfrom ) ) {
$redir = Linker::makeExternalLink( $rdfrom, $rdfrom );
$outputPage->addSubtitle( "<span class=\"mw-redirectedfrom\">" .
$context->msg( 'redirectedfrom' )->rawParams( $redir )->parse()
@@ -1125,8 +1127,10 @@ class Article implements Page {
* @return bool
*/
public function showPatrolFooter() {
- global $wgUseNPPatrol, $wgUseRCPatrol, $wgUseFilePatrol;
-
+ $mainConfig = MediaWikiServices::getInstance()->getMainConfig();
+ $useNPPatrol = $mainConfig->get( 'UseNPPatrol' );
+ $useRCPatrol = $mainConfig->get( 'UseRCPatrol' );
+ $useFilePatrol = $mainConfig->get( 'UseFilePatrol' );
// Allow hooks to decide whether to not output this at all
if ( !$this->getHookRunner()->onArticleShowPatrolFooter( $this ) ) {
return false;
@@ -1138,8 +1142,8 @@ class Article implements Page {
$rc = false;
if ( !$this->getContext()->getAuthority()->probablyCan( 'patrol', $title )
- || !( $wgUseRCPatrol || $wgUseNPPatrol
- || ( $wgUseFilePatrol && $title->inNamespace( NS_FILE ) ) )
+ || !( $useRCPatrol || $useNPPatrol
+ || ( $useFilePatrol && $title->inNamespace( NS_FILE ) ) )
) {
// Patrolling is disabled or the user isn't allowed to
return false;
@@ -1199,7 +1203,7 @@ class Article implements Page {
// to get the recentchanges row belonging to that entry
// (with rc_type = RC_LOG, rc_log_type = upload).
$recentFileUpload = false;
- if ( ( !$rc || $rc->getAttribute( 'rc_patrolled' ) ) && $wgUseFilePatrol
+ if ( ( !$rc || $rc->getAttribute( 'rc_patrolled' ) ) && $useFilePatrol
&& $title->getNamespace() === NS_FILE ) {
// Retrieve timestamp of most recent upload
$newestUploadTimestamp = $dbr->selectField(
@@ -1304,7 +1308,7 @@ class Article implements Page {
* namespace, show the default message text. To be called from Article::view().
*/
public function showMissingArticle() {
- global $wgSend404Code;
+ $send404Code = MediaWikiServices::getInstance()->getMainConfig()->get( 'Send404Code' );
$outputPage = $this->getContext()->getOutput();
// Whether the page is a root user page of an existing user (but not a subpage)
@@ -1402,7 +1406,7 @@ class Article implements Page {
);
}
- if ( !$this->mPage->hasViewableContent() && $wgSend404Code && !$validUserPage ) {
+ if ( !$this->mPage->hasViewableContent() && $send404Code && !$validUserPage ) {
// If there's no backing content, send a 404 Not Found
// for better machine handling of broken links.
$this->getContext()->getRequest()->response()->statusHeader( 404 );
diff --git a/includes/page/ImagePage.php b/includes/page/ImagePage.php
index 8fb5585708ee..228b535820fb 100644
--- a/includes/page/ImagePage.php
+++ b/includes/page/ImagePage.php
@@ -89,7 +89,7 @@ class ImagePage extends Article {
}
public function view() {
- global $wgShowEXIF;
+ $showEXIF = MediaWikiServices::getInstance()->getMainConfig()->get( 'ShowEXIF' );
// For action=render, include body text only; none of the image extras
if ( $this->viewIsRenderAction ) {
@@ -127,7 +127,7 @@ class ImagePage extends Article {
return;
}
- if ( $wgShowEXIF && $this->displayImg->exists() ) {
+ if ( $showEXIF && $this->displayImg->exists() ) {
// @todo FIXME: Bad interface, see note on MediaHandler::formatMetadata().
$formattedMetadata = $this->displayImg->formatMetadata( $this->getContext() );
} else {
@@ -317,7 +317,7 @@ class ImagePage extends Article {
}
/**
- * Returns language code to be used for displaying the image, based on request context and
+ * Returns language code to be used for dispaying the image, based on request context and
* languages available in the file.
*
* @param WebRequest $request
@@ -340,8 +340,10 @@ class ImagePage extends Article {
}
protected function openShowImage() {
- global $wgEnableUploads, $wgSend404Code, $wgSVGMaxSize;
-
+ $mainConfig = MediaWikiServices::getInstance()->getMainConfig();
+ $enableUploads = $mainConfig->get( 'EnableUploads' );
+ $send404Code = $mainConfig->get( 'Send404Code' );
+ $svgMaxSize = $mainConfig->get( 'SVGMaxSize' );
$this->loadFile();
$out = $this->getContext()->getOutput();
$user = $this->getContext()->getUser();
@@ -405,7 +407,7 @@ class ImagePage extends Article {
// so all thumbs less than or equal that are shown.
if ( ( ( $size[0] <= $width_orig && $size[1] <= $height_orig )
|| ( $this->displayImg->isVectorized()
- && max( $size[0], $size[1] ) <= $wgSVGMaxSize )
+ && max( $size[0], $size[1] ) <= $svgMaxSize )
)
&& $size[0] != $width && $size[1] != $height
&& $size[0] != $maxWidth && $size[1] != $maxHeight
@@ -522,11 +524,11 @@ class ImagePage extends Article {
$thumb2 = '';
}
- global $wgScript;
+ $script = MediaWikiServices::getInstance()->getMainConfig()->get( 'Script' );
$formParams = [
'name' => 'pageselector',
- 'action' => $wgScript,
+ 'action' => $script,
];
$options = [];
for ( $i = 1; $i <= $count; $i++ ) {
@@ -647,7 +649,7 @@ EOT
);
}
- if ( $wgEnableUploads &&
+ if ( $enableUploads &&
$this->getContext()->getAuthority()->isAllowed( 'upload' )
) {
// Only show an upload link if the user can upload
@@ -666,7 +668,7 @@ EOT
// by Article::View().
$out->setRobotPolicy( 'noindex,nofollow' );
$out->wrapWikiMsg( "<div id='mw-imagepage-nofile' class='plainlinks'>\n$1\n</div>", $nofile );
- if ( !$this->getPage()->getId() && $wgSend404Code ) {
+ if ( !$this->getPage()->getId() && $send404Code ) {
// If there is no image, no shared image, and no description page,
// output a 404, to be consistent with Article::showMissingArticle.
$request->response()->statusHeader( 404 );
@@ -1079,7 +1081,7 @@ EOT
* @return string HTML to insert underneath image.
*/
protected function doRenderLangOpt( array $langChoices, $renderLang ) {
- global $wgScript;
+ $script = MediaWikiServices::getInstance()->getMainConfig()->get( 'Script' );
$opts = '';
$matchedRenderLang = $this->displayImg->getMatchedLanguage( $renderLang );
@@ -1113,7 +1115,7 @@ EOT
$formContents .= Html::hidden( 'title', $this->getTitle()->getPrefixedDBkey() );
$langSelectLine = Html::rawElement( 'div', [ 'id' => 'mw-imglangselector-line' ],
- Html::rawElement( 'form', [ 'action' => $wgScript ], $formContents )
+ Html::rawElement( 'form', [ 'action' => $script ], $formContents )
);
return $langSelectLine;
}
@@ -1151,9 +1153,9 @@ EOT
* @phan-return array<int,array{0:int,1:int}>
*/
protected function getThumbSizes( $origWidth, $origHeight ) {
- global $wgImageLimits;
+ $imageLimits = MediaWikiServices::getInstance()->getMainConfig()->get( 'ImageLimits' );
if ( $this->displayImg->getRepo()->canTransformVia404() ) {
- $thumbSizes = $wgImageLimits;
+ $thumbSizes = $imageLimits;
// Also include the full sized resolution in the list, so
// that users know they can get it. This will link to the
// original file asset if mustRender() === false. In the case
diff --git a/includes/page/WikiPage.php b/includes/page/WikiPage.php
index 879762c3900c..bff2e452f9fc 100644
--- a/includes/page/WikiPage.php
+++ b/includes/page/WikiPage.php
@@ -368,7 +368,7 @@ class WikiPage implements Page, IDBAccessObject, PageRecord {
* - joins: (array) to include in the `$join_conds` to `IDatabase->select()`
*/
public static function getQueryInfo() {
- global $wgPageLanguageUseDB;
+ $pageLanguageUseDB = MediaWikiServices::getInstance()->getMainConfig()->get( 'PageLanguageUseDB' );
$ret = [
'tables' => [ 'page' ],
@@ -389,7 +389,7 @@ class WikiPage implements Page, IDBAccessObject, PageRecord {
'joins' => [],
];
- if ( $wgPageLanguageUseDB ) {
+ if ( $pageLanguageUseDB ) {
$ret['fields'][] = 'page_lang';
}
@@ -972,7 +972,7 @@ class WikiPage implements Page, IDBAccessObject, PageRecord {
* @return bool
*/
public function isCountable( $editInfo = false ) {
- global $wgArticleCountMethod;
+ $articleCountMethod = MediaWikiServices::getInstance()->getMainConfig()->get( 'ArticleCountMethod' );
// NOTE: Keep in sync with DerivedPageDataUpdater::isCountable.
@@ -996,7 +996,7 @@ class WikiPage implements Page, IDBAccessObject, PageRecord {
$hasLinks = null;
- if ( $wgArticleCountMethod === 'link' ) {
+ if ( $articleCountMethod === 'link' ) {
// nasty special case to avoid re-parsing to detect links
if ( $editInfo ) {
@@ -1935,8 +1935,8 @@ class WikiPage implements Page, IDBAccessObject, PageRecord {
$tags = [],
$undidRevId = 0
) {
- global $wgUseNPPatrol, $wgUseRCPatrol;
-
+ $useNPPatrol = MediaWikiServices::getInstance()->getMainConfig()->get( 'UseNPPatrol' );
+ $useRCPatrol = MediaWikiServices::getInstance()->getMainConfig()->get( 'UseRCPatrol' );
if ( !( $summary instanceof CommentStoreComment ) ) {
$summary = CommentStoreComment::newUnsavedComment( trim( $summary ) );
}
@@ -1965,7 +1965,7 @@ class WikiPage implements Page, IDBAccessObject, PageRecord {
);
}
- $needsPatrol = $wgUseRCPatrol || ( $wgUseNPPatrol && !$this->exists() );
+ $needsPatrol = $useRCPatrol || ( $useNPPatrol && !$this->exists() );
// TODO: this logic should not be in the storage layer, it's here for compatibility
// with 1.31 behavior. Applying the 'autopatrol' right should be done in the same
@@ -2656,13 +2656,14 @@ class WikiPage implements Page, IDBAccessObject, PageRecord {
* @return bool True if deletion would be batched, false otherwise
*/
public function isBatchedDelete( $safetyMargin = 0 ) {
- global $wgDeleteRevisionsBatchSize;
+ $deleteRevisionsBatchSize = MediaWikiServices::getInstance()
+ ->getMainConfig()->get( 'DeleteRevisionsBatchSize' );
$dbr = wfGetDB( DB_REPLICA );
$revCount = $this->getRevisionStore()->countRevisionsByPageId( $dbr, $this->getId() );
$revCount += $safetyMargin;
- return $revCount >= $wgDeleteRevisionsBatchSize;
+ return $revCount >= $deleteRevisionsBatchSize;
}
/**
@@ -2981,9 +2982,9 @@ class WikiPage implements Page, IDBAccessObject, PageRecord {
* @param Title $title
*/
private static function purgeInterwikiCheckKey( Title $title ) {
- global $wgEnableScaryTranscluding;
+ $enableScaryTranscluding = MediaWikiServices::getInstance()->getMainConfig()->get( 'EnableScaryTranscluding' );
- if ( !$wgEnableScaryTranscluding ) {
+ if ( !$enableScaryTranscluding ) {
return; // @todo: perhaps this wiki is only used as a *source* for content?
}
@@ -3294,8 +3295,8 @@ class WikiPage implements Page, IDBAccessObject, PageRecord {
* @return string
*/
public function getWikiDisplayName() {
- global $wgSitename;
- return $wgSitename;
+ $sitename = MediaWikiServices::getInstance()->getMainConfig()->get( 'Sitename' );
+ return $sitename;
}
/**
diff --git a/includes/parser/CacheTime.php b/includes/parser/CacheTime.php
index df4b1f88adb4..de3c1530cfd5 100644
--- a/includes/parser/CacheTime.php
+++ b/includes/parser/CacheTime.php
@@ -24,6 +24,7 @@
use MediaWiki\Json\JsonUnserializable;
use MediaWiki\Json\JsonUnserializableTrait;
use MediaWiki\Json\JsonUnserializer;
+use MediaWiki\MediaWikiServices;
use MediaWiki\Parser\ParserCacheMetadata;
use Wikimedia\Reflection\GhostFieldAccessTrait;
@@ -140,7 +141,7 @@ class CacheTime implements ParserCacheMetadata, JsonUnserializable {
* @return int
*/
public function getCacheExpiry(): int {
- global $wgParserCacheExpireTime;
+ $parserCacheExpireTime = MediaWikiServices::getInstance()->getMainConfig()->get( 'ParserCacheExpireTime' );
// NOTE: keep support for undocumented used of -1 to mean "not cacheable".
if ( $this->mCacheTime !== '' && $this->mCacheTime < 0 ) {
@@ -150,9 +151,9 @@ class CacheTime implements ParserCacheMetadata, JsonUnserializable {
$expire = $this->mCacheExpiry;
if ( $expire === null ) {
- $expire = $wgParserCacheExpireTime;
+ $expire = $parserCacheExpireTime;
} else {
- $expire = min( $expire, $wgParserCacheExpireTime );
+ $expire = min( $expire, $parserCacheExpireTime );
}
if ( $expire <= 0 ) {
@@ -178,13 +179,13 @@ class CacheTime implements ParserCacheMetadata, JsonUnserializable {
* @return bool
*/
public function expired( $touched ) {
- global $wgCacheEpoch;
+ $cacheEpoch = MediaWikiServices::getInstance()->getMainConfig()->get( 'CacheEpoch' );
$expiry = MWTimestamp::convert( TS_MW, MWTimestamp::time() - $this->getCacheExpiry() );
return !$this->isCacheable() // parser says it's not cacheable
|| $this->getCacheTime() < $touched
- || $this->getCacheTime() <= $wgCacheEpoch
+ || $this->getCacheTime() <= $cacheEpoch
|| $this->getCacheTime() < $expiry; // expiry period has passed
}
diff --git a/includes/parser/LinkHolderArray.php b/includes/parser/LinkHolderArray.php
index 6215a623d08c..cd32b5ded420 100644
--- a/includes/parser/LinkHolderArray.php
+++ b/includes/parser/LinkHolderArray.php
@@ -109,8 +109,8 @@ class LinkHolderArray {
* @return bool
*/
public function isBig() {
- global $wgLinkHolderBatchSize;
- return $this->size > $wgLinkHolderBatchSize;
+ $linkHolderBatchSize = MediaWikiServices::getInstance()->getMainConfig()->get( 'LinkHolderBatchSize' );
+ return $this->size > $linkHolderBatchSize;
}
/**
diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php
index 7aecbb68a0ce..7f7a05710a99 100644
--- a/includes/parser/Parser.php
+++ b/includes/parser/Parser.php
@@ -2207,10 +2207,13 @@ class Parser {
* @return string|null Rel attribute for $url
*/
public static function getExternalLinkRel( $url = false, LinkTarget $title = null ) {
- global $wgNoFollowLinks, $wgNoFollowNsExceptions, $wgNoFollowDomainExceptions;
+ $mainConfig = MediaWikiServices::getInstance()->getMainConfig();
+ $noFollowLinks = $mainConfig->get( 'NoFollowLinks' );
+ $noFollowNsExceptions = $mainConfig->get( 'NoFollowNsExceptions' );
+ $noFollowDomainExceptions = $mainConfig->get( 'NoFollowDomainExceptions' );
$ns = $title ? $title->getNamespace() : false;
- if ( $wgNoFollowLinks && !in_array( $ns, $wgNoFollowNsExceptions )
- && !wfMatchesDomainList( $url, $wgNoFollowDomainExceptions )
+ if ( $noFollowLinks && !in_array( $ns, $noFollowNsExceptions )
+ && !wfMatchesDomainList( $url, $noFollowDomainExceptions )
) {
return 'nofollow';
}
diff --git a/includes/parser/ParserOutput.php b/includes/parser/ParserOutput.php
index ee0d3621541a..1424109d246a 100644
--- a/includes/parser/ParserOutput.php
+++ b/includes/parser/ParserOutput.php
@@ -960,15 +960,16 @@ class ParserOutput extends CacheTime {
public function addExternalLink( $url ) {
# We don't register links pointing to our own server, unless... :-)
- global $wgServer, $wgRegisterInternalExternals;
-
+ $config = MediaWikiServices::getInstance()->getMainConfig();
+ $server = $config->get( 'Server' );
+ $registerInternalExternals = $config->get( 'RegisterInternalExternals' );
# Replace unnecessary URL escape codes with the referenced character
# This prevents spammers from hiding links from the filters
$url = Parser::normalizeLinkUrl( $url );
$registerExternalLink = true;
- if ( !$wgRegisterInternalExternals ) {
- $registerExternalLink = !self::isLinkInternal( $wgServer, $url );
+ if ( !$registerInternalExternals ) {
+ $registerExternalLink = !self::isLinkInternal( $server, $url );
}
if ( $registerExternalLink ) {
$this->mExternalLinks[$url] = 1;
@@ -1694,9 +1695,9 @@ class ParserOutput extends CacheTime {
* @return bool
*/
public function hasReducedExpiry(): bool {
- global $wgParserCacheExpireTime;
+ $parserCacheExpireTime = MediaWikiServices::getInstance()->getMainConfig()->get( 'ParserCacheExpireTime' );
- return $this->getCacheExpiry() < $wgParserCacheExpireTime;
+ return $this->getCacheExpiry() < $parserCacheExpireTime;
}
/**
diff --git a/includes/rcfeed/IRCColourfulRCFeedFormatter.php b/includes/rcfeed/IRCColourfulRCFeedFormatter.php
index 9e06c355a1c7..619867a45bdd 100644
--- a/includes/rcfeed/IRCColourfulRCFeedFormatter.php
+++ b/includes/rcfeed/IRCColourfulRCFeedFormatter.php
@@ -36,8 +36,12 @@ class IRCColourfulRCFeedFormatter implements RCFeedFormatter {
* @return string|null
*/
public function getLine( array $feed, RecentChange $rc, $actionComment ) {
- global $wgUseRCPatrol, $wgUseNPPatrol, $wgLocalInterwikis,
- $wgCanonicalServer, $wgScript;
+ $mainConfig = MediaWikiServices::getInstance()->getMainConfig();
+ $useRCPatrol = $mainConfig->get( 'UseRCPatrol' );
+ $useNPPatrol = $mainConfig->get( 'UseNPPatrol' );
+ $localInterwikis = $mainConfig->get( 'LocalInterwikis' );
+ $canonicalServer = $mainConfig->get( 'CanonicalServer' );
+ $script = $mainConfig->get( 'Script' );
$attribs = $rc->getAttributes();
if ( $attribs['rc_type'] == RC_CATEGORIZE ) {
// Don't send RC_CATEGORIZE events to IRC feed (T127360)
@@ -57,13 +61,13 @@ class IRCColourfulRCFeedFormatter implements RCFeedFormatter {
if ( $attribs['rc_type'] == RC_LOG ) {
$url = '';
} else {
- $url = $wgCanonicalServer . $wgScript;
+ $url = $canonicalServer . $script;
if ( $attribs['rc_type'] == RC_NEW ) {
$query = '?oldid=' . $attribs['rc_this_oldid'];
} else {
$query = '?diff=' . $attribs['rc_this_oldid'] . '&oldid=' . $attribs['rc_last_oldid'];
}
- if ( $wgUseRCPatrol || ( $attribs['rc_type'] == RC_NEW && $wgUseNPPatrol ) ) {
+ if ( $useRCPatrol || ( $attribs['rc_type'] == RC_NEW && $useNPPatrol ) ) {
$query .= '&rcid=' . $attribs['rc_id'];
}
@@ -100,7 +104,7 @@ class IRCColourfulRCFeedFormatter implements RCFeedFormatter {
$comment = self::cleanupForIRC( $store->getComment( 'rc_comment', $attribs )->text );
$flag = '';
if ( !$attribs['rc_patrolled']
- && ( $wgUseRCPatrol || $attribs['rc_type'] == RC_NEW && $wgUseNPPatrol )
+ && ( $useRCPatrol || $attribs['rc_type'] == RC_NEW && $useNPPatrol )
) {
$flag .= '!';
}
@@ -108,9 +112,9 @@ class IRCColourfulRCFeedFormatter implements RCFeedFormatter {
. ( $attribs['rc_minor'] ? "M" : "" ) . ( $attribs['rc_bot'] ? "B" : "" );
}
- if ( $feed['add_interwiki_prefix'] === true && $wgLocalInterwikis ) {
+ if ( $feed['add_interwiki_prefix'] === true && $localInterwikis ) {
// we use the first entry in $wgLocalInterwikis in recent changes feeds
- $prefix = $wgLocalInterwikis[0];
+ $prefix = $localInterwikis[0];
} elseif ( $feed['add_interwiki_prefix'] ) {
$prefix = $feed['add_interwiki_prefix'];
} else {
diff --git a/includes/rcfeed/MachineReadableRCFeedFormatter.php b/includes/rcfeed/MachineReadableRCFeedFormatter.php
index 9e6deb67c127..d57d7d72d90e 100644
--- a/includes/rcfeed/MachineReadableRCFeedFormatter.php
+++ b/includes/rcfeed/MachineReadableRCFeedFormatter.php
@@ -19,6 +19,8 @@
* @file
*/
+use MediaWiki\MediaWikiServices;
+
/**
* Abstract class so there can be multiple formatters outputting the same data
*
@@ -42,8 +44,10 @@ abstract class MachineReadableRCFeedFormatter implements RCFeedFormatter {
* @return string|null
*/
public function getLine( array $feed, RecentChange $rc, $actionComment ) {
- global $wgCanonicalServer, $wgServerName, $wgScriptPath;
-
+ $mainConfig = MediaWikiServices::getInstance()->getMainConfig();
+ $canonicalServer = $mainConfig->get( 'CanonicalServer' );
+ $serverName = $mainConfig->get( 'ServerName' );
+ $scriptPath = $mainConfig->get( 'ScriptPath' );
$packet = [
// Usually, RC ID is exposed only for patrolling purposes,
// but there is no real reason not to expose it in other cases,
@@ -64,10 +68,10 @@ abstract class MachineReadableRCFeedFormatter implements RCFeedFormatter {
$type = $rc->getAttribute( 'rc_type' );
if ( $type == RC_EDIT || $type == RC_NEW ) {
- global $wgUseRCPatrol, $wgUseNPPatrol;
-
+ $useRCPatrol = MediaWikiServices::getInstance()->getMainConfig()->get( 'UseRCPatrol' );
+ $useNPPatrol = MediaWikiServices::getInstance()->getMainConfig()->get( 'UseNPPatrol' );
$packet['minor'] = (bool)$rc->getAttribute( 'rc_minor' );
- if ( $wgUseRCPatrol || ( $type == RC_NEW && $wgUseNPPatrol ) ) {
+ if ( $useRCPatrol || ( $type == RC_NEW && $useNPPatrol ) ) {
$packet['patrolled'] = (bool)$rc->getAttribute( 'rc_patrolled' );
}
}
@@ -121,10 +125,10 @@ abstract class MachineReadableRCFeedFormatter implements RCFeedFormatter {
break;
}
- $packet['server_url'] = $wgCanonicalServer;
- $packet['server_name'] = $wgServerName;
+ $packet['server_url'] = $canonicalServer;
+ $packet['server_name'] = $serverName;
- $packet['server_script_path'] = $wgScriptPath ?: '/';
+ $packet['server_script_path'] = $scriptPath ?: '/';
$packet['wiki'] = WikiMap::getCurrentWikiId();
return $this->formatArray( $packet );
diff --git a/includes/resourceloader/ResourceLoader.php b/includes/resourceloader/ResourceLoader.php
index af804044bed5..4a4fc48810ee 100644
--- a/includes/resourceloader/ResourceLoader.php
+++ b/includes/resourceloader/ResourceLoader.php
@@ -1074,9 +1074,9 @@ class ResourceLoader implements LoggerAwareInterface {
* @return string Sanitized text that can be returned to the user
*/
protected static function formatExceptionNoComment( Throwable $e ) {
- global $wgShowExceptionDetails;
+ $showExceptionDetails = MediaWikiServices::getInstance()->getMainConfig()->get( 'ShowExceptionDetails' );
- if ( !$wgShowExceptionDetails ) {
+ if ( !$showExceptionDetails ) {
return MWExceptionHandler::getPublicLogMessage( $e );
}
@@ -1709,9 +1709,10 @@ MESSAGE;
*/
public static function inDebugMode() {
if ( self::$debugMode === null ) {
- global $wgRequest, $wgResourceLoaderDebug;
+ global $wgRequest;
+ $resourceLoaderDebug = MediaWikiServices::getInstance()->getMainConfig()->get( 'ResourceLoaderDebug' );
$str = $wgRequest->getRawVal( 'debug',
- $wgRequest->getCookie( 'resourceLoaderDebug', '', $wgResourceLoaderDebug ? 'true' : '' )
+ $wgRequest->getCookie( 'resourceLoaderDebug', '', $resourceLoaderDebug ? 'true' : '' )
);
self::$debugMode = ResourceLoaderContext::debugFromString( $str );
}
diff --git a/includes/resourceloader/ResourceLoaderImage.php b/includes/resourceloader/ResourceLoaderImage.php
index 5af93e165fd7..2d109d00cb25 100644
--- a/includes/resourceloader/ResourceLoaderImage.php
+++ b/includes/resourceloader/ResourceLoaderImage.php
@@ -399,8 +399,8 @@ class ResourceLoaderImage {
* @return string|bool PNG image data, or false on failure
*/
protected function rasterize( $svg ) {
- global $wgSVGConverter, $wgSVGConverterPath;
-
+ $svgConverter = MediaWikiServices::getInstance()->getMainConfig()->get( 'SVGConverter' );
+ $svgConverterPath = MediaWikiServices::getInstance()->getMainConfig()->get( 'SVGConverterPath' );
// This code should be factored out to a separate method on SvgHandler, or perhaps a separate
// class, with a separate set of configuration settings.
//
@@ -420,10 +420,10 @@ class ResourceLoaderImage {
$svg = $this->massageSvgPathdata( $svg );
// Sometimes this might be 'rsvg-secure'. Long as it's rsvg.
- if ( strpos( $wgSVGConverter, 'rsvg' ) === 0 ) {
+ if ( strpos( $svgConverter, 'rsvg' ) === 0 ) {
$command = 'rsvg-convert';
- if ( $wgSVGConverterPath ) {
- $command = Shell::escape( "$wgSVGConverterPath/" ) . $command;
+ if ( $svgConverterPath ) {
+ $command = Shell::escape( "{$svgConverterPath}/" ) . $command;
}
$process = proc_open(
diff --git a/includes/revisiondelete/RevisionDeleteUser.php b/includes/revisiondelete/RevisionDeleteUser.php
index 9959541a739d..097c5f66544b 100644
--- a/includes/revisiondelete/RevisionDeleteUser.php
+++ b/includes/revisiondelete/RevisionDeleteUser.php
@@ -21,6 +21,7 @@
* @ingroup RevisionDelete
*/
+use MediaWiki\MediaWikiServices;
use MediaWiki\Revision\RevisionRecord;
use Wikimedia\Rdbms\IDatabase;
@@ -44,7 +45,8 @@ class RevisionDeleteUser {
* @return bool True on success, false on failure (e.g. invalid user ID)
*/
private static function setUsernameBitfields( $name, $userId, $op, IDatabase $dbw = null ) {
- global $wgActorTableSchemaMigrationStage;
+ $actorTableSchemaMigrationStage = MediaWikiServices::getInstance()
+ ->getMainConfig()->get( 'ActorTableSchemaMigrationStage' );
if ( !$userId || ( $op !== '|' && $op !== '&' ) ) {
return false;
@@ -76,7 +78,7 @@ class RevisionDeleteUser {
# write stage, because the stage determines how we find the rows to
# delete. The write stage determines whether or not to write to
# rev_actor and revision_actor_temp which is not relevant here.
- if ( $wgActorTableSchemaMigrationStage & SCHEMA_COMPAT_READ_TEMP ) {
+ if ( $actorTableSchemaMigrationStage & SCHEMA_COMPAT_READ_TEMP ) {
$ids = $dbw->selectFieldValues(
'revision_actor_temp', 'revactor_rev', [ 'revactor_actor' => $actorId ], __METHOD__
);
diff --git a/includes/search/SearchHighlighter.php b/includes/search/SearchHighlighter.php
index aefad9813e39..b7d705722c4d 100644
--- a/includes/search/SearchHighlighter.php
+++ b/includes/search/SearchHighlighter.php
@@ -63,7 +63,8 @@ class SearchHighlighter {
$contextlines = self::DEFAULT_CONTEXT_LINES,
$contextchars = self::DEFAULT_CONTEXT_CHARS
) {
- global $wgSearchHighlightBoundaries;
+ $searchHighlightBoundaries = MediaWikiServices::getInstance()
+ ->getMainConfig()->get( 'SearchHighlightBoundaries' );
if ( $text == '' ) {
return '';
@@ -168,7 +169,7 @@ class SearchHighlighter {
}
}
$anyterm = implode( '|', $terms );
- $phrase = implode( "$wgSearchHighlightBoundaries+", $terms );
+ $phrase = implode( "{$searchHighlightBoundaries}+", $terms );
// @todo FIXME: A hack to scale contextchars, a correct solution
// would be to have contextchars actually be char and not byte
// length, and do proper utf-8 substrings and lengths everywhere,
@@ -176,8 +177,8 @@ class SearchHighlighter {
$scale = strlen( $anyterm ) / mb_strlen( $anyterm );
$contextchars = intval( $contextchars * $scale );
- $patPre = "(^|$wgSearchHighlightBoundaries)";
- $patPost = "($wgSearchHighlightBoundaries|$)";
+ $patPre = "(^|{$searchHighlightBoundaries})";
+ $patPost = "({$searchHighlightBoundaries}|$)";
$pat1 = "/(" . $phrase . ")/ui";
$pat2 = "/$patPre(" . $anyterm . ")$patPost/ui";
diff --git a/includes/search/SqlSearchResult.php b/includes/search/SqlSearchResult.php
index 80eebdc67848..6db05a5119d3 100644
--- a/includes/search/SqlSearchResult.php
+++ b/includes/search/SqlSearchResult.php
@@ -1,5 +1,4 @@
<?php
-
/**
* Search engine result issued from SearchData search engines.
*
@@ -22,6 +21,8 @@
* @ingroup Search
*/
+use MediaWiki\MediaWikiServices;
+
class SqlSearchResult extends RevisionSearchResult {
/** @var string[] */
private $terms;
@@ -47,12 +48,13 @@ class SqlSearchResult extends RevisionSearchResult {
* @return string Highlighted text snippet, null (and not '') if not supported
*/
public function getTextSnippet( $terms = [] ) {
- global $wgAdvancedSearchHighlighting;
+ $advancedSearchHighlighting = MediaWikiServices::getInstance()
+ ->getMainConfig()->get( 'AdvancedSearchHighlighting' );
$this->initText();
$h = new SearchHighlighter();
if ( count( $this->terms ) > 0 ) {
- if ( $wgAdvancedSearchHighlighting ) {
+ if ( $advancedSearchHighlighting ) {
return $h->highlightText( $this->mText, $this->terms );
} else {
return $h->highlightSimple( $this->mText, $this->terms );
diff --git a/includes/search/SqlSearchResultSet.php b/includes/search/SqlSearchResultSet.php
index 96801f82b751..d18c6d64fc21 100644
--- a/includes/search/SqlSearchResultSet.php
+++ b/includes/search/SqlSearchResultSet.php
@@ -1,5 +1,6 @@
<?php
+use MediaWiki\MediaWikiServices;
use Wikimedia\Rdbms\IResultWrapper;
/**
@@ -52,7 +53,7 @@ class SqlSearchResultSet extends SearchResultSet {
if ( $this->results === null ) {
$this->results = [];
$this->resultSet->rewind();
- $terms = \MediaWiki\MediaWikiServices::getInstance()->getContentLanguage()
+ $terms = MediaWikiServices::getInstance()->getContentLanguage()
->convertForSearchResult( $this->terms );
while ( ( $row = $this->resultSet->fetchObject() ) !== false ) {
$result = new SqlSearchResult(
diff --git a/includes/session/Session.php b/includes/session/Session.php
index ffd639201f3b..048bd7f0cb3d 100644
--- a/includes/session/Session.php
+++ b/includes/session/Session.php
@@ -23,6 +23,7 @@
namespace MediaWiki\Session;
+use MediaWiki\MediaWikiServices;
use Psr\Log\LoggerInterface;
use User;
use WebRequest;
@@ -410,9 +411,11 @@ class Session implements \Countable, \Iterator, \ArrayAccess {
* @return string[] Encryption key, HMAC key
*/
private function getSecretKeys() {
- global $wgSessionSecret, $wgSecretKey, $wgSessionPbkdf2Iterations;
-
- $wikiSecret = $wgSessionSecret ?: $wgSecretKey;
+ $mainConfig = MediaWikiServices::getInstance()->getMainConfig();
+ $sessionSecret = $mainConfig->get( 'SessionSecret' );
+ $secretKey = $mainConfig->get( 'SecretKey' );
+ $sessionPbkdf2Iterations = $mainConfig->get( 'SessionPbkdf2Iterations' );
+ $wikiSecret = $sessionSecret ?: $secretKey;
$userSecret = $this->get( 'wsSessionSecret', null );
if ( $userSecret === null ) {
$userSecret = \MWCryptRand::generateHex( 32 );
@@ -420,7 +423,7 @@ class Session implements \Countable, \Iterator, \ArrayAccess {
}
$iterations = $this->get( 'wsSessionPbkdf2Iterations', null );
if ( $iterations === null ) {
- $iterations = $wgSessionPbkdf2Iterations;
+ $iterations = $sessionPbkdf2Iterations;
$this->set( 'wsSessionPbkdf2Iterations', $iterations );
}
@@ -436,7 +439,7 @@ class Session implements \Countable, \Iterator, \ArrayAccess {
* @return array
*/
private static function getEncryptionAlgorithm() {
- global $wgSessionInsecureSecrets;
+ $sessionInsecureSecrets = MediaWikiServices::getInstance()->getMainConfig()->get( 'SessionInsecureSecrets' );
if ( self::$encryptionAlgorithm === null ) {
if ( function_exists( 'openssl_encrypt' ) ) {
@@ -451,7 +454,7 @@ class Session implements \Countable, \Iterator, \ArrayAccess {
}
}
- if ( $wgSessionInsecureSecrets ) {
+ if ( $sessionInsecureSecrets ) {
// @todo: import a pure-PHP library for AES instead of this
self::$encryptionAlgorithm = [ 'insecure' ];
return self::$encryptionAlgorithm;
diff --git a/includes/shell/Shell.php b/includes/shell/Shell.php
index 9253649f8769..a1deb147e038 100644
--- a/includes/shell/Shell.php
+++ b/includes/shell/Shell.php
@@ -183,11 +183,11 @@ class Shell {
public static function makeScriptCommand(
string $script, array $parameters, $options = []
): Command {
- global $wgPhpCli;
+ $phpCli = MediaWikiServices::getInstance()->getMainConfig()->get( 'PhpCli' );
// Give site config file a chance to run the script in a wrapper.
// The caller may likely want to call wfBasename() on $script.
Hooks::runner()->onWfShellWikiCmd( $script, $parameters, $options );
- $cmd = [ $options['php'] ?? $wgPhpCli ];
+ $cmd = [ $options['php'] ?? $phpCli ];
if ( isset( $options['wrapper'] ) ) {
$cmd[] = $options['wrapper'];
}
diff --git a/includes/site/Site.php b/includes/site/Site.php
index 66577b7233ad..50a41c2c6995 100644
--- a/includes/site/Site.php
+++ b/includes/site/Site.php
@@ -654,10 +654,10 @@ class Site implements Serializable {
* @return Site
*/
public static function newForType( $siteType ) {
- global $wgSiteTypes;
+ $siteTypes = MediaWikiServices::getInstance()->getMainConfig()->get( 'SiteTypes' );
- if ( array_key_exists( $siteType, $wgSiteTypes ) ) {
- return new $wgSiteTypes[$siteType]();
+ if ( array_key_exists( $siteType, $siteTypes ) ) {
+ return new $siteTypes[$siteType]();
}
return new Site();
diff --git a/includes/specials/SpecialUserLogin.php b/includes/specials/SpecialUserLogin.php
index 7483bd8a4ff4..27cbd2febe94 100644
--- a/includes/specials/SpecialUserLogin.php
+++ b/includes/specials/SpecialUserLogin.php
@@ -23,6 +23,7 @@
use MediaWiki\Auth\AuthManager;
use MediaWiki\Logger\LoggerFactory;
+use MediaWiki\MediaWikiServices;
/**
* Implements Special:UserLogin
@@ -102,7 +103,7 @@ class SpecialUserLogin extends LoginSignupSpecialPage {
* @param StatusValue|null $extraMessages
*/
protected function successfulAction( $direct = false, $extraMessages = null ) {
- global $wgSecureLogin;
+ $secureLogin = MediaWikiServices::getInstance()->getMainConfig()->get( 'SecureLogin' );
$user = $this->targetUser ?: $this->getUser();
$session = $this->getRequest()->getSession();
@@ -115,7 +116,7 @@ class SpecialUserLogin extends LoginSignupSpecialPage {
if ( $user->requiresHTTPS() ) {
$this->mStickHTTPS = true;
}
- $session->setForceHTTPS( $wgSecureLogin && $this->mStickHTTPS );
+ $session->setForceHTTPS( $secureLogin && $this->mStickHTTPS );
// If the user does not have a session cookie at this point, they probably need to
// do something to their browser.
diff --git a/includes/upload/UploadBase.php b/includes/upload/UploadBase.php
index c7dc7712e659..58979dbaa262 100644
--- a/includes/upload/UploadBase.php
+++ b/includes/upload/UploadBase.php
@@ -141,9 +141,9 @@ abstract class UploadBase {
* @return bool
*/
public static function isEnabled() {
- global $wgEnableUploads;
+ $enableUploads = MediaWikiServices::getInstance()->getMainConfig()->get( 'EnableUploads' );
- return $wgEnableUploads && wfIniGetBool( 'file_uploads' );
+ return $enableUploads && wfIniGetBool( 'file_uploads' );
}
/**
@@ -444,26 +444,27 @@ abstract class UploadBase {
* @return array|bool True if the file is verified, an array otherwise
*/
protected function verifyMimeType( $mime ) {
- global $wgVerifyMimeType, $wgVerifyMimeTypeIE;
- if ( $wgVerifyMimeType ) {
+ $verifyMimeType = MediaWikiServices::getInstance()->getMainConfig()->get( 'VerifyMimeType' );
+ $verifyMimeTypeIE = MediaWikiServices::getInstance()->getMainConfig()->get( 'VerifyMimeTypeIE' );
+ if ( $verifyMimeType ) {
wfDebug( "mime: <$mime> extension: <{$this->mFinalExtension}>" );
- global $wgMimeTypeExclusions;
- if ( self::checkFileExtension( $mime, $wgMimeTypeExclusions ) ) {
+ $mimeTypeExclusions = MediaWikiServices::getInstance()->getMainConfig()->get( 'MimeTypeExclusions' );
+ if ( self::checkFileExtension( $mime, $mimeTypeExclusions ) ) {
return [ 'filetype-badmime', $mime ];
}
- if ( $wgVerifyMimeTypeIE ) {
+ if ( $verifyMimeTypeIE ) {
# Check what Internet Explorer would detect
$fp = fopen( $this->mTempPath, 'rb' );
if ( $fp ) {
$chunk = fread( $fp, 256 );
fclose( $fp );
- $magic = MediaWiki\MediaWikiServices::getInstance()->getMimeAnalyzer();
+ $magic = MediaWikiServices::getInstance()->getMimeAnalyzer();
$extMime = $magic->getMimeTypeFromExtensionOrNull( (string)$this->mFinalExtension ) ?? '';
$ieTypes = $magic->getIEMimeTypes( $this->mTempPath, $chunk, $extMime );
foreach ( $ieTypes as $ieType ) {
- if ( self::checkFileExtension( $ieType, $wgMimeTypeExclusions ) ) {
+ if ( self::checkFileExtension( $ieType, $mimeTypeExclusions ) ) {
return [ 'filetype-bad-ie-mime', $ieType ];
}
}
@@ -480,18 +481,19 @@ abstract class UploadBase {
* @return array|bool True of the file is verified, array otherwise.
*/
protected function verifyFile() {
- global $wgVerifyMimeType, $wgDisableUploadScriptChecks;
-
+ $config = MediaWikiServices::getInstance()->getMainConfig();
+ $verifyMimeType = $config->get( 'VerifyMimeType' );
+ $disableUploadScriptChecks = $config->get( 'DisableUploadScriptChecks' );
$status = $this->verifyPartialFile();
if ( $status !== true ) {
return $status;
}
- $mwProps = new MWFileProps( MediaWiki\MediaWikiServices::getInstance()->getMimeAnalyzer() );
+ $mwProps = new MWFileProps( MediaWikiServices::getInstance()->getMimeAnalyzer() );
$this->mFileProps = $mwProps->getPropsFromPath( $this->mTempPath, $this->mFinalExtension );
$mime = $this->mFileProps['mime'];
- if ( $wgVerifyMimeType ) {
+ if ( $verifyMimeType ) {
# XXX: Missing extension will be caught by validateName() via getTitle()
if ( (string)$this->mFinalExtension !== '' &&
!$this->verifyExtension( $mime, $this->mFinalExtension )
@@ -501,7 +503,7 @@ abstract class UploadBase {
}
# check for htmlish code and javascript
- if ( !$wgDisableUploadScriptChecks ) {
+ if ( !$disableUploadScriptChecks ) {
if ( $this->mFinalExtension == 'svg' || $mime == 'image/svg+xml' ) {
$svgStatus = $this->detectScriptInSvg( $this->mTempPath, false );
if ( $svgStatus !== false ) {
@@ -543,12 +545,13 @@ abstract class UploadBase {
* @return array|bool True if the file is valid, else an array with error message key.
*/
protected function verifyPartialFile() {
- global $wgAllowJavaUploads, $wgDisableUploadScriptChecks;
-
+ $config = MediaWikiServices::getInstance()->getMainConfig();
+ $allowJavaUploads = $config->get( 'AllowJavaUploads' );
+ $disableUploadScriptChecks = $config->get( 'DisableUploadScriptChecks' );
# getTitle() sets some internal parameters like $this->mFinalExtension
$this->getTitle();
- $mwProps = new MWFileProps( MediaWiki\MediaWikiServices::getInstance()->getMimeAnalyzer() );
+ $mwProps = new MWFileProps( MediaWikiServices::getInstance()->getMimeAnalyzer() );
$this->mFileProps = $mwProps->getPropsFromPath( $this->mTempPath, $this->mFinalExtension );
# check MIME type, if desired
@@ -559,7 +562,7 @@ abstract class UploadBase {
}
# check for htmlish code and javascript
- if ( !$wgDisableUploadScriptChecks ) {
+ if ( !$disableUploadScriptChecks ) {
if ( self::detectScript( $this->mTempPath, $mime, $this->mFinalExtension ) ) {
return [ 'uploadscripted' ];
}
@@ -573,7 +576,7 @@ abstract class UploadBase {
# Check for Java applets, which if uploaded can bypass cross-site
# restrictions.
- if ( !$wgAllowJavaUploads ) {
+ if ( !$allowJavaUploads ) {
$this->mJavaDetected = false;
$zipStatus = ZipDirectoryReader::read( $this->mTempPath,
[ $this, 'zipEntryCallback' ] );
@@ -790,10 +793,11 @@ abstract class UploadBase {
* 2 => int The number of extensions that are allowed.
*/
private function checkUnwantedFileExtensions( $fileExtension ) {
- global $wgCheckFileExtensions, $wgFileExtensions, $wgLang;
-
- if ( $wgCheckFileExtensions ) {
- $extensions = array_unique( $wgFileExtensions );
+ global $wgLang;
+ $checkFileExtensions = MediaWikiServices::getInstance()->getMainConfig()->get( 'CheckFileExtensions' );
+ $fileExtensions = MediaWikiServices::getInstance()->getMainConfig()->get( 'FileExtensions' );
+ if ( $checkFileExtensions ) {
+ $extensions = array_unique( $fileExtensions );
if ( !$this->checkFileExtension( $fileExtension, $extensions ) ) {
return [
$fileExtension,
@@ -812,13 +816,13 @@ abstract class UploadBase {
* @return array warnings
*/
private function checkFileSize( $fileSize ) {
- global $wgUploadSizeWarning;
+ $uploadSizeWarning = MediaWikiServices::getInstance()->getMainConfig()->get( 'UploadSizeWarning' );
$warnings = [];
- if ( $wgUploadSizeWarning && ( $fileSize > $wgUploadSizeWarning ) ) {
+ if ( $uploadSizeWarning && ( $fileSize > $uploadSizeWarning ) ) {
$warnings['large-file'] = [
- Message::sizeParam( $wgUploadSizeWarning ),
+ Message::sizeParam( $uploadSizeWarning ),
Message::sizeParam( $fileSize ),
];
}
@@ -1046,7 +1050,7 @@ abstract class UploadBase {
// FIXME: Sometimes we mTempPath isn't set yet here, possibly due to an unrealistic
// or incomplete test case in UploadBaseTest (T272328)
if ( $this->mTempPath !== null ) {
- $magic = MediaWiki\MediaWikiServices::getInstance()->getMimeAnalyzer();
+ $magic = MediaWikiServices::getInstance()->getMimeAnalyzer();
$mime = $magic->guessMimeType( $this->mTempPath );
if ( $mime !== 'unknown/unknown' ) {
# Get a space separated list of extensions
@@ -1065,10 +1069,13 @@ abstract class UploadBase {
}
// Don't allow users to override the list of prohibited file extensions (check file extension)
- global $wgCheckFileExtensions, $wgStrictFileExtensions;
- global $wgFileExtensions, $wgProhibitedFileExtensions;
+ $config = MediaWikiServices::getInstance()->getMainConfig();
+ $checkFileExtensions = $config->get( 'CheckFileExtensions' );
+ $strictFileExtensions = $config->get( 'StrictFileExtensions' );
+ $fileExtensions = $config->get( 'FileExtensions' );
+ $prohibitedFileExtensions = $config->get( 'ProhibitedFileExtensions' );
- $blackListedExtensions = self::checkFileExtensionList( $ext, $wgProhibitedFileExtensions );
+ $blackListedExtensions = self::checkFileExtensionList( $ext, $prohibitedFileExtensions );
if ( $this->mFinalExtension == '' ) {
$this->mTitleError = self::FILETYPE_MISSING;
@@ -1076,8 +1083,8 @@ abstract class UploadBase {
return $this->mTitle;
} elseif ( $blackListedExtensions ||
- ( $wgCheckFileExtensions && $wgStrictFileExtensions &&
- !$this->checkFileExtension( $this->mFinalExtension, $wgFileExtensions ) )
+ ( $checkFileExtensions && $strictFileExtensions &&
+ !$this->checkFileExtension( $this->mFinalExtension, $fileExtensions ) )
) {
$this->mBlackListedExtensions = $blackListedExtensions;
$this->mTitleError = self::FILETYPE_BADTYPE;
@@ -1263,7 +1270,7 @@ abstract class UploadBase {
* @return bool
*/
public static function verifyExtension( $mime, $extension ) {
- $magic = MediaWiki\MediaWikiServices::getInstance()->getMimeAnalyzer();
+ $magic = MediaWikiServices::getInstance()->getMimeAnalyzer();
if ( !$mime || $mime == 'unknown' || $mime == 'unknown/unknown' ) {
if ( !$magic->isRecognizableExtension( $extension ) ) {
@@ -1430,8 +1437,8 @@ abstract class UploadBase {
* @return bool True if the file contains an encoding that could be misinterpreted
*/
public static function checkXMLEncodingMissmatch( $file ) {
- global $wgSVGMetadataCutoff;
- $contents = file_get_contents( $file, false, null, 0, $wgSVGMetadataCutoff );
+ $svgMetadataCutoff = MediaWikiServices::getInstance()->getMainConfig()->get( 'SVGMetadataCutoff' );
+ $contents = file_get_contents( $file, false, null, 0, $svgMetadataCutoff );
$encodingRegex = '!encoding[ \t\n\r]*=[ \t\n\r]*[\'"](.*?)[\'"]!si';
if ( preg_match( "!<\?xml\b(.*?)\?>!si", $contents, $matches ) ) {
@@ -1879,26 +1886,29 @@ abstract class UploadBase {
* If textual feedback is missing but a virus was found, this function returns true.
*/
public static function detectVirus( $file ) {
- global $wgAntivirus, $wgAntivirusSetup, $wgAntivirusRequired, $wgOut;
-
- if ( !$wgAntivirus ) {
+ global $wgOut;
+ $mainConfig = MediaWikiServices::getInstance()->getMainConfig();
+ $antivirus = $mainConfig->get( 'Antivirus' );
+ $antivirusSetup = $mainConfig->get( 'AntivirusSetup' );
+ $antivirusRequired = $mainConfig->get( 'AntivirusRequired' );
+ if ( !$antivirus ) {
wfDebug( __METHOD__ . ": virus scanner disabled" );
return null;
}
- if ( !$wgAntivirusSetup[$wgAntivirus] ) {
- wfDebug( __METHOD__ . ": unknown virus scanner: $wgAntivirus" );
+ if ( !$antivirusSetup[$antivirus] ) {
+ wfDebug( __METHOD__ . ": unknown virus scanner: {$antivirus}" );
$wgOut->wrapWikiMsg( "<div class=\"error\">\n$1\n</div>",
- [ 'virus-badscanner', $wgAntivirus ] );
+ [ 'virus-badscanner', $antivirus ] );
- return wfMessage( 'virus-unknownscanner' )->text() . " $wgAntivirus";
+ return wfMessage( 'virus-unknownscanner' )->text() . " {$antivirus}";
}
# look up scanner configuration
- $command = $wgAntivirusSetup[$wgAntivirus]['command'];
- $exitCodeMap = $wgAntivirusSetup[$wgAntivirus]['codemap'];
- $msgPattern = $wgAntivirusSetup[$wgAntivirus]['messagepattern'] ?? null;
+ $command = $antivirusSetup[$antivirus]['command'];
+ $exitCodeMap = $antivirusSetup[$antivirus]['codemap'];
+ $msgPattern = $antivirusSetup[$antivirus]['messagepattern'] ?? null;
if ( strpos( $command, "%f" ) === false ) {
# simple pattern: append file to scan
@@ -1935,7 +1945,7 @@ abstract class UploadBase {
# scan failed (code was mapped to false by $exitCodeMap)
wfDebug( __METHOD__ . ": failed to scan $file (code $exitCode)." );
- $output = $wgAntivirusRequired
+ $output = $antivirusRequired
? wfMessage( 'virus-scanfailed', [ $exitCode ] )->text()
: null;
} elseif ( $mappedCode === AV_SCAN_ABORTED ) {
@@ -2204,16 +2214,16 @@ abstract class UploadBase {
* @return int
*/
public static function getMaxUploadSize( $forType = null ) {
- global $wgMaxUploadSize;
+ $maxUploadSize = MediaWikiServices::getInstance()->getMainConfig()->get( 'MaxUploadSize' );
- if ( is_array( $wgMaxUploadSize ) ) {
- if ( $forType !== null && isset( $wgMaxUploadSize[$forType] ) ) {
- return $wgMaxUploadSize[$forType];
+ if ( is_array( $maxUploadSize ) ) {
+ if ( $forType !== null && isset( $maxUploadSize[$forType] ) ) {
+ return $maxUploadSize[$forType];
} else {
- return $wgMaxUploadSize['*'];
+ return $maxUploadSize['*'];
}
} else {
- return intval( $wgMaxUploadSize );
+ return intval( $maxUploadSize );
}
}
diff --git a/includes/upload/UploadFromUrl.php b/includes/upload/UploadFromUrl.php
index 05533f86852a..21f1f5d8d319 100644
--- a/includes/upload/UploadFromUrl.php
+++ b/includes/upload/UploadFromUrl.php
@@ -61,9 +61,9 @@ class UploadFromUrl extends UploadBase {
* @return bool
*/
public static function isEnabled() {
- global $wgAllowCopyUploads;
+ $allowCopyUploads = MediaWikiServices::getInstance()->getMainConfig()->get( 'AllowCopyUploads' );
- return $wgAllowCopyUploads && parent::isEnabled();
+ return $allowCopyUploads && parent::isEnabled();
}
/**
@@ -75,8 +75,8 @@ class UploadFromUrl extends UploadBase {
* @return bool
*/
public static function isAllowedHost( $url ) {
- global $wgCopyUploadsDomains;
- if ( !count( $wgCopyUploadsDomains ) ) {
+ $copyUploadsDomains = MediaWikiServices::getInstance()->getMainConfig()->get( 'CopyUploadsDomains' );
+ if ( !count( $copyUploadsDomains ) ) {
return true;
}
$parsedUrl = wfParseUrl( $url );
@@ -84,7 +84,7 @@ class UploadFromUrl extends UploadBase {
return false;
}
$valid = false;
- foreach ( $wgCopyUploadsDomains as $domain ) {
+ foreach ( $copyUploadsDomains as $domain ) {
// See if the domain for the upload matches this allowed domain
$domainPieces = explode( '.', $domain );
$uploadDomainPieces = explode( '.', $parsedUrl['host'] );
@@ -249,7 +249,8 @@ class UploadFromUrl extends UploadBase {
* @return Status
*/
protected function reallyFetchFile( $httpOptions = [] ) {
- global $wgCopyUploadProxy, $wgCopyUploadTimeout;
+ $copyUploadProxy = MediaWikiServices::getInstance()->getMainConfig()->get( 'CopyUploadProxy' );
+ $copyUploadTimeout = MediaWikiServices::getInstance()->getMainConfig()->get( 'CopyUploadTimeout' );
if ( $this->mTempPath === false ) {
return Status::newFatal( 'tmp-create-error' );
}
@@ -266,12 +267,12 @@ class UploadFromUrl extends UploadBase {
$options = $httpOptions + [ 'followRedirects' => false ];
- if ( $wgCopyUploadProxy !== false ) {
- $options['proxy'] = $wgCopyUploadProxy;
+ if ( $copyUploadProxy !== false ) {
+ $options['proxy'] = $copyUploadProxy;
}
- if ( $wgCopyUploadTimeout && !isset( $options['timeout'] ) ) {
- $options['timeout'] = $wgCopyUploadTimeout;
+ if ( $copyUploadTimeout && !isset( $options['timeout'] ) ) {
+ $options['timeout'] = $copyUploadTimeout;
}
wfDebugLog(
'fileupload',
diff --git a/includes/upload/UploadStash.php b/includes/upload/UploadStash.php
index e3ad48f783a2..eab47962a300 100644
--- a/includes/upload/UploadStash.php
+++ b/includes/upload/UploadStash.php
@@ -20,6 +20,7 @@
* @file
*/
+use MediaWiki\MediaWikiServices;
use MediaWiki\User\UserIdentity;
/**
@@ -207,7 +208,7 @@ class UploadStash {
);
}
- $mwProps = new MWFileProps( MediaWiki\MediaWikiServices::getInstance()->getMimeAnalyzer() );
+ $mwProps = new MWFileProps( MediaWikiServices::getInstance()->getMimeAnalyzer() );
$fileProps = $mwProps->getPropsFromPath( $path, true );
wfDebug( __METHOD__ . " stashing file at '$path'" );
@@ -472,7 +473,8 @@ class UploadStash {
* @return string
*/
public static function getExtensionForPath( $path ) {
- global $wgProhibitedFileExtensions;
+ $prohibitedFileExtensions = MediaWikiServices::getInstance()
+ ->getMainConfig()->get( 'ProhibitedFileExtensions' );
// Does this have an extension?
$n = strrpos( $path, '.' );
@@ -480,13 +482,13 @@ class UploadStash {
$extension = $n ? substr( $path, $n + 1 ) : '';
} else {
// If not, assume that it should be related to the MIME type of the original file.
- $magic = MediaWiki\MediaWikiServices::getInstance()->getMimeAnalyzer();
+ $magic = MediaWikiServices::getInstance()->getMimeAnalyzer();
$mimeType = $magic->guessMimeType( $path );
$extension = $magic->getExtensionFromMimeTypeOrNull( $mimeType );
}
$extension = File::normalizeExtension( $extension );
- if ( in_array( $extension, $wgProhibitedFileExtensions ) ) {
+ if ( in_array( $extension, $prohibitedFileExtensions ) ) {
// The file should already be checked for being evil.
// However, if somehow we got here, we definitely
// don't want to give it an extension of .php and
diff --git a/includes/user/BotPassword.php b/includes/user/BotPassword.php
index 3e9f662964ff..bee64f475572 100644
--- a/includes/user/BotPassword.php
+++ b/includes/user/BotPassword.php
@@ -194,8 +194,9 @@ class BotPassword implements IDBAccessObject {
* @return string
*/
public static function getSeparator() {
- global $wgUserrightsInterwikiDelimiter;
- return $wgUserrightsInterwikiDelimiter;
+ $userrightsInterwikiDelimiter = MediaWikiServices::getInstance()
+ ->getMainConfig()->get( 'UserrightsInterwikiDelimiter' );
+ return $userrightsInterwikiDelimiter;
}
/**
@@ -303,9 +304,9 @@ class BotPassword implements IDBAccessObject {
public static function invalidateAllPasswordsForCentralId( $centralId ) {
wfDeprecated( __METHOD__, '1.37' );
- global $wgEnableBotPasswords;
+ $enableBotPasswords = MediaWikiServices::getInstance()->getMainConfig()->get( 'EnableBotPasswords' );
- if ( !$wgEnableBotPasswords ) {
+ if ( !$enableBotPasswords ) {
return false;
}
@@ -341,9 +342,9 @@ class BotPassword implements IDBAccessObject {
public static function removeAllPasswordsForCentralId( $centralId ) {
wfDeprecated( __METHOD__, '1.37' );
- global $wgEnableBotPasswords;
+ $enableBotPasswords = MediaWikiServices::getInstance()->getMainConfig()->get( 'EnableBotPasswords' );
- if ( !$wgEnableBotPasswords ) {
+ if ( !$enableBotPasswords ) {
return false;
}
@@ -402,9 +403,9 @@ class BotPassword implements IDBAccessObject {
* @return Status On success, the good status's value is the new Session object
*/
public static function login( $username, $password, WebRequest $request ) {
- global $wgEnableBotPasswords, $wgPasswordAttemptThrottle;
-
- if ( !$wgEnableBotPasswords ) {
+ $enableBotPasswords = MediaWikiServices::getInstance()->getMainConfig()->get( 'EnableBotPasswords' );
+ $passwordAttemptThrottle = MediaWikiServices::getInstance()->getMainConfig()->get( 'PasswordAttemptThrottle' );
+ if ( !$enableBotPasswords ) {
return Status::newFatal( 'botpasswords-disabled' );
}
@@ -431,8 +432,8 @@ class BotPassword implements IDBAccessObject {
}
$throttle = null;
- if ( !empty( $wgPasswordAttemptThrottle ) ) {
- $throttle = new Throttler( $wgPasswordAttemptThrottle, [
+ if ( !empty( $passwordAttemptThrottle ) ) {
+ $throttle = new Throttler( $passwordAttemptThrottle, [
'type' => 'botpassword',
'cache' => ObjectCache::getLocalClusterInstance(),
] );
diff --git a/includes/user/User.php b/includes/user/User.php
index aaf225b95f2d..f7741644c766 100644
--- a/includes/user/User.php
+++ b/includes/user/User.php
@@ -1009,11 +1009,11 @@ class User implements Authority, UserIdentity, UserEmailContact {
* @since 1.23
*/
public function checkPasswordValidity( $password ) {
- global $wgPasswordPolicy;
+ $passwordPolicy = MediaWikiServices::getInstance()->getMainConfig()->get( 'PasswordPolicy' );
$upp = new UserPasswordPolicy(
- $wgPasswordPolicy['policies'],
- $wgPasswordPolicy['checks']
+ $passwordPolicy['policies'],
+ $passwordPolicy['checks']
);
$status = Status::newGood( [] );
@@ -1450,8 +1450,8 @@ class User implements Authority, UserIdentity, UserEmailContact {
* @return bool True if rate limited
*/
public function isPingLimitable() {
- global $wgRateLimitsExcludedIPs;
- if ( IPUtils::isInRanges( $this->getRequest()->getIP(), $wgRateLimitsExcludedIPs ) ) {
+ $rateLimitsExcludedIPs = MediaWikiServices::getInstance()->getMainConfig()->get( 'RateLimitsExcludedIPs' );
+ if ( IPUtils::isInRanges( $this->getRequest()->getIP(), $rateLimitsExcludedIPs ) ) {
// No other good way currently to disable rate limits
// for specific IPs. :P
// But this is a crappy hack and should die.
@@ -1485,14 +1485,14 @@ class User implements Authority, UserIdentity, UserEmailContact {
return $result;
}
- global $wgRateLimits;
- if ( !isset( $wgRateLimits[$action] ) ) {
+ $rateLimits = MediaWikiServices::getInstance()->getMainConfig()->get( 'RateLimits' );
+ if ( !isset( $rateLimits[$action] ) ) {
return false;
}
$limits = array_merge(
[ '&can-bypass' => true ],
- $wgRateLimits[$action]
+ $rateLimits[$action]
);
// Some groups shouldn't trigger the ping limiter, ever
@@ -2168,7 +2168,8 @@ class User implements Authority, UserIdentity, UserEmailContact {
* @return string|null Token
*/
public function getToken( $forceCreation = true ) {
- global $wgAuthenticationTokenVersion;
+ $authenticationTokenVersion = MediaWikiServices::getInstance()
+ ->getMainConfig()->get( 'AuthenticationTokenVersion' );
$this->load();
if ( !$this->mToken && $forceCreation ) {
@@ -2186,13 +2187,13 @@ class User implements Authority, UserIdentity, UserEmailContact {
return MWCryptRand::generateHex( self::TOKEN_LENGTH );
}
- if ( $wgAuthenticationTokenVersion === null ) {
+ if ( $authenticationTokenVersion === null ) {
// $wgAuthenticationTokenVersion not in use, so return the raw secret
return $this->mToken;
}
// $wgAuthenticationTokenVersion in use, so hmac it.
- $ret = MWCryptHash::hmac( $wgAuthenticationTokenVersion, $this->mToken, false );
+ $ret = MWCryptHash::hmac( $authenticationTokenVersion, $this->mToken, false );
// The raw hash can be overly long. Shorten it up.
$len = max( 32, self::TOKEN_LENGTH );
@@ -2268,9 +2269,9 @@ class User implements Authority, UserIdentity, UserEmailContact {
* @return Status
*/
public function setEmailWithConfirmation( string $str ) {
- global $wgEnableEmail, $wgEmailAuthentication;
-
- if ( !$wgEnableEmail ) {
+ $enableEmail = MediaWikiServices::getInstance()->getMainConfig()->get( 'EnableEmail' );
+ $emailAuthentication = MediaWikiServices::getInstance()->getMainConfig()->get( 'EmailAuthentication' );
+ if ( !$enableEmail ) {
return Status::newFatal( 'emaildisabled' );
}
@@ -2282,7 +2283,7 @@ class User implements Authority, UserIdentity, UserEmailContact {
$type = $oldaddr != '' ? 'changed' : 'set';
$notificationResult = null;
- if ( $wgEmailAuthentication && $type === 'changed' ) {
+ if ( $emailAuthentication && $type === 'changed' ) {
// Send the user an email notifying the user of the change in registered
// email address on their previous email address
$change = $str != '' ? 'changed' : 'removed';
@@ -2297,7 +2298,7 @@ class User implements Authority, UserIdentity, UserEmailContact {
$this->setEmail( $str );
- if ( $str !== '' && $wgEmailAuthentication ) {
+ if ( $str !== '' && $emailAuthentication ) {
// Send a confirmation request to the new address if needed
$result = $this->sendConfirmationMail( $type );
@@ -2367,10 +2368,10 @@ class User implements Authority, UserIdentity, UserEmailContact {
* @deprecated since 1.26 Applications should use the OAuth extension
*/
public function getTokenFromOption( $oname ) {
- global $wgHiddenPrefs;
+ $hiddenPrefs = MediaWikiServices::getInstance()->getMainConfig()->get( 'HiddenPrefs' );
$id = $this->getId();
- if ( !$id || in_array( $oname, $wgHiddenPrefs ) ) {
+ if ( !$id || in_array( $oname, $hiddenPrefs ) ) {
return false;
}
@@ -2395,8 +2396,8 @@ class User implements Authority, UserIdentity, UserEmailContact {
* @see setOption()
*/
public function resetTokenFromOption( $oname ) {
- global $wgHiddenPrefs;
- if ( in_array( $oname, $wgHiddenPrefs ) ) {
+ $hiddenPrefs = MediaWikiServices::getInstance()->getMainConfig()->get( 'HiddenPrefs' );
+ if ( in_array( $oname, $hiddenPrefs ) ) {
return false;
}
@@ -2432,11 +2433,12 @@ class User implements Authority, UserIdentity, UserEmailContact {
* @return bool
*/
public function requiresHTTPS() {
- global $wgForceHTTPS, $wgSecureLogin;
- if ( $wgForceHTTPS ) {
+ $forceHTTPS = MediaWikiServices::getInstance()->getMainConfig()->get( 'ForceHTTPS' );
+ $secureLogin = MediaWikiServices::getInstance()->getMainConfig()->get( 'SecureLogin' );
+ if ( $forceHTTPS ) {
return true;
}
- if ( !$wgSecureLogin ) {
+ if ( !$secureLogin ) {
return false;
}
return MediaWikiServices::getInstance()
@@ -2589,8 +2591,8 @@ class User implements Authority, UserIdentity, UserEmailContact {
* @return bool True or false
*/
public function useRCPatrol() {
- global $wgUseRCPatrol;
- return $wgUseRCPatrol && $this->isAllowedAny( 'patrol', 'patrolmarks' );
+ $useRCPatrol = MediaWikiServices::getInstance()->getMainConfig()->get( 'UseRCPatrol' );
+ return $useRCPatrol && $this->isAllowedAny( 'patrol', 'patrolmarks' );
}
/**
@@ -2598,9 +2600,10 @@ class User implements Authority, UserIdentity, UserEmailContact {
* @return bool True or false
*/
public function useNPPatrol() {
- global $wgUseRCPatrol, $wgUseNPPatrol;
+ $useRCPatrol = MediaWikiServices::getInstance()->getMainConfig()->get( 'UseRCPatrol' );
+ $useNPPatrol = MediaWikiServices::getInstance()->getMainConfig()->get( 'UseNPPatrol' );
return (
- ( $wgUseRCPatrol || $wgUseNPPatrol )
+ ( $useRCPatrol || $useNPPatrol )
&& ( $this->isAllowedAny( 'patrol', 'patrolmarks' ) )
);
}
@@ -2610,9 +2613,10 @@ class User implements Authority, UserIdentity, UserEmailContact {
* @return bool True or false
*/
public function useFilePatrol() {
- global $wgUseRCPatrol, $wgUseFilePatrol;
+ $useRCPatrol = MediaWikiServices::getInstance()->getMainConfig()->get( 'UseRCPatrol' );
+ $useFilePatrol = MediaWikiServices::getInstance()->getMainConfig()->get( 'UseFilePatrol' );
return (
- ( $wgUseRCPatrol || $wgUseFilePatrol )
+ ( $useRCPatrol || $useFilePatrol )
&& ( $this->isAllowedAny( 'patrol', 'patrolmarks' ) )
);
}
@@ -2635,11 +2639,11 @@ class User implements Authority, UserIdentity, UserEmailContact {
* @return string|false 'newcomer', 'learner', or 'experienced', false for anonymous users
*/
public function getExperienceLevel() {
- global $wgLearnerEdits,
- $wgExperiencedUserEdits,
- $wgLearnerMemberSince,
- $wgExperiencedUserMemberSince;
-
+ $mainConfig = MediaWikiServices::getInstance()->getMainConfig();
+ $learnerEdits = $mainConfig->get( 'LearnerEdits' );
+ $experiencedUserEdits = $mainConfig->get( 'ExperiencedUserEdits' );
+ $learnerMemberSince = $mainConfig->get( 'LearnerMemberSince' );
+ $experiencedUserMemberSince = $mainConfig->get( 'ExperiencedUserMemberSince' );
if ( $this->isAnon() ) {
return false;
}
@@ -2647,20 +2651,20 @@ class User implements Authority, UserIdentity, UserEmailContact {
$editCount = $this->getEditCount();
$registration = $this->getRegistration();
$now = time();
- $learnerRegistration = wfTimestamp( TS_MW, $now - $wgLearnerMemberSince * 86400 );
- $experiencedRegistration = wfTimestamp( TS_MW, $now - $wgExperiencedUserMemberSince * 86400 );
+ $learnerRegistration = wfTimestamp( TS_MW, $now - $learnerMemberSince * 86400 );
+ $experiencedRegistration = wfTimestamp( TS_MW, $now - $experiencedUserMemberSince * 86400 );
if ( $registration === null ) {
// for some very old accounts, this information is missing in the database
// treat them as old enough to be 'experienced'
$registration = $experiencedRegistration;
}
- if ( $editCount < $wgLearnerEdits ||
+ if ( $editCount < $learnerEdits ||
$registration > $learnerRegistration ) {
return 'newcomer';
}
- if ( $editCount > $wgExperiencedUserEdits &&
+ if ( $editCount > $experiencedUserEdits &&
$registration <= $experiencedRegistration
) {
return 'experienced';
@@ -3263,12 +3267,12 @@ class User implements Authority, UserIdentity, UserEmailContact {
* @return Status
*/
public function sendMail( $subject, $body, $from = null, $replyto = null ) {
- global $wgPasswordSender;
+ $passwordSender = MediaWikiServices::getInstance()->getMainConfig()->get( 'PasswordSender' );
if ( $from instanceof User ) {
$sender = MailAddress::newFromUser( $from );
} else {
- $sender = new MailAddress( $wgPasswordSender,
+ $sender = new MailAddress( $passwordSender,
wfMessage( 'emailsender' )->inContentLanguage()->text() );
}
$to = MailAddress::newFromUser( $this );
@@ -3289,9 +3293,10 @@ class User implements Authority, UserIdentity, UserEmailContact {
* @return string New token
*/
protected function confirmationToken( &$expiration ) {
- global $wgUserEmailConfirmationTokenExpiry;
+ $userEmailConfirmationTokenExpiry = MediaWikiServices::getInstance()
+ ->getMainConfig()->get( 'UserEmailConfirmationTokenExpiry' );
$now = time();
- $expires = $now + $wgUserEmailConfirmationTokenExpiry;
+ $expires = $now + $userEmailConfirmationTokenExpiry;
$expiration = wfTimestamp( TS_MW, $expires );
$this->load();
$token = MWCryptRand::generateHex( 32 );
@@ -3390,8 +3395,9 @@ class User implements Authority, UserIdentity, UserEmailContact {
* @return bool
*/
public function canSendEmail() {
- global $wgEnableEmail, $wgEnableUserEmail;
- if ( !$wgEnableEmail || !$wgEnableUserEmail || !$this->isAllowed( 'sendemail' ) ) {
+ $enableEmail = MediaWikiServices::getInstance()->getMainConfig()->get( 'EnableEmail' );
+ $enableUserEmail = MediaWikiServices::getInstance()->getMainConfig()->get( 'EnableUserEmail' );
+ if ( !$enableEmail || !$enableUserEmail || !$this->isAllowed( 'sendemail' ) ) {
return false;
}
$hookErr = $this->isEmailConfirmed();
@@ -3419,7 +3425,7 @@ class User implements Authority, UserIdentity, UserEmailContact {
* @return bool
*/
public function isEmailConfirmed(): bool {
- global $wgEmailAuthentication;
+ $emailAuthentication = MediaWikiServices::getInstance()->getMainConfig()->get( 'EmailAuthentication' );
$this->load();
// Avoid PHP 7.1 warning of passing $this by reference
$user = $this;
@@ -3431,7 +3437,7 @@ class User implements Authority, UserIdentity, UserEmailContact {
if ( !Sanitizer::validateEmail( $this->getEmail() ) ) {
return false;
}
- if ( $wgEmailAuthentication && !$this->getEmailAuthenticationTimestamp() ) {
+ if ( $emailAuthentication && !$this->getEmailAuthenticationTimestamp() ) {
return false;
}
return true;
@@ -3445,8 +3451,8 @@ class User implements Authority, UserIdentity, UserEmailContact {
* @return bool
*/
public function isEmailConfirmationPending() {
- global $wgEmailAuthentication;
- return $wgEmailAuthentication &&
+ $emailAuthentication = MediaWikiServices::getInstance()->getMainConfig()->get( 'EmailAuthentication' );
+ return $emailAuthentication &&
!$this->isEmailConfirmed() &&
$this->mEmailToken &&
$this->mEmailTokenExpires > wfTimestamp();
diff --git a/includes/user/UserRightsProxy.php b/includes/user/UserRightsProxy.php
index 0b8acb5ef9d3..1cc16c099404 100644
--- a/includes/user/UserRightsProxy.php
+++ b/includes/user/UserRightsProxy.php
@@ -72,8 +72,8 @@ class UserRightsProxy implements UserIdentity {
* @return bool
*/
public static function validDatabase( $dbDomain ) {
- global $wgLocalDatabases;
- return in_array( $dbDomain, $wgLocalDatabases );
+ $localDatabases = MediaWikiServices::getInstance()->getMainConfig()->get( 'LocalDatabases' );
+ return in_array( $dbDomain, $localDatabases );
}
/**
@@ -125,12 +125,13 @@ class UserRightsProxy implements UserIdentity {
* @return null|UserRightsProxy
*/
private static function newFromLookup( $dbDomain, $field, $value, $ignoreInvalidDB = false ) {
- global $wgSharedDB, $wgSharedTables;
+ $sharedDB = MediaWikiServices::getInstance()->getMainConfig()->get( 'SharedDB' );
+ $sharedTables = MediaWikiServices::getInstance()->getMainConfig()->get( 'SharedTables' );
// If the user table is shared, perform the user query on it,
// but don't pass it to the UserRightsProxy,
// as user rights are normally not shared.
- if ( $wgSharedDB && in_array( 'user', $wgSharedTables ) ) {
- $userdb = self::getDB( $wgSharedDB, $ignoreInvalidDB );
+ if ( $sharedDB && in_array( 'user', $sharedTables ) ) {
+ $userdb = self::getDB( $sharedDB, $ignoreInvalidDB );
} else {
$userdb = self::getDB( $dbDomain, $ignoreInvalidDB );
}