Mass conversion to NamespaceInfo
authorAryeh Gregor <ayg@aryeh.name>
Sun, 5 Aug 2018 17:58:51 +0000 (20:58 +0300)
committerdaniel <dkinzler@wikimedia.org>
Tue, 7 May 2019 20:44:56 +0000 (22:44 +0200)
Change-Id: I2fef157ceec772f304c0923a1cd8c0eef2e82a0f

68 files changed:
includes/EditPage.php
includes/Linker.php
includes/MovePage.php
includes/OutputPage.php
includes/ProtectionForm.php
includes/SiteStatsInit.php
includes/Title.php
includes/TrackingCategories.php
includes/actions/InfoAction.php
includes/api/ApiBase.php
includes/api/ApiHelp.php
includes/api/ApiPageSet.php
includes/api/ApiQueryAllDeletedRevisions.php
includes/api/ApiQueryAllPages.php
includes/api/ApiQueryAllRevisions.php
includes/api/ApiQueryInfo.php
includes/api/ApiQuerySiteinfo.php
includes/changes/ChangesFeed.php
includes/content/ContentHandler.php
includes/editpage/TextboxBuilder.php
includes/export/DumpNotalkFilter.php
includes/export/XmlDumpWriter.php
includes/filerepo/FileRepo.php
includes/gallery/TraditionalImageGallery.php
includes/import/WikiImporter.php
includes/page/Article.php
includes/resourceloader/ResourceLoaderStartUpModule.php
includes/skins/Skin.php
includes/skins/SkinTemplate.php
includes/specialpage/ChangesListSpecialPage.php
includes/specials/SpecialAncientpages.php
includes/specials/SpecialContributions.php
includes/specials/SpecialDeadendpages.php
includes/specials/SpecialDeletedContributions.php
includes/specials/SpecialEditWatchlist.php
includes/specials/SpecialFewestrevisions.php
includes/specials/SpecialListGroupRights.php
includes/specials/SpecialLonelypages.php
includes/specials/SpecialMostcategories.php
includes/specials/SpecialMostinterwikis.php
includes/specials/SpecialMovepage.php
includes/specials/SpecialPasswordPolicies.php
includes/specials/SpecialRandompage.php
includes/specials/SpecialSearch.php
includes/specials/SpecialShortpages.php
includes/specials/SpecialStatistics.php
includes/specials/SpecialUncategorizedpages.php
includes/specials/SpecialWithoutinterwiki.php
includes/specials/forms/UploadForm.php
includes/specials/pagers/ContribsPager.php
includes/title/NaiveImportTitleFactory.php
includes/title/NamespaceImportTitleFactory.php
includes/title/SubpageImportTitleFactory.php
includes/user/ExternalUserNames.php
includes/widget/search/SearchFormWidget.php
languages/Language.php
maintenance/cleanupCaps.php
maintenance/cleanupTitles.php
maintenance/generateSitemap.php
maintenance/namespaceDupes.php
maintenance/rebuildFileCache.php
tests/parser/ParserTestRunner.php
tests/phpunit/MediaWikiTestCase.php
tests/phpunit/includes/PagePropsTest.php
tests/phpunit/includes/RevisionDbTestBase.php
tests/phpunit/includes/api/ApiBaseTest.php
tests/phpunit/includes/editpage/TextboxBuilderTest.php
tests/phpunit/structure/ApiStructureTest.php

index 1d9ff05..2d5b9e2 100644 (file)
@@ -2609,7 +2609,8 @@ ERROR;
                                LogEventsList::showLogExtract(
                                        $out,
                                        'block',
-                                       MWNamespace::getCanonicalName( NS_USER ) . ':' . $block->getTarget(),
+                                       MediaWikiServices::getInstance()->getNamespaceInfo()->
+                                               getCanonicalName( NS_USER ) . ':' . $block->getTarget(),
                                        '',
                                        [
                                                'lim' => 1,
@@ -4451,7 +4452,9 @@ ERROR;
        protected function addPageProtectionWarningHeaders() {
                $out = $this->context->getOutput();
                if ( $this->mTitle->isProtected( 'edit' ) &&
-                       MWNamespace::getRestrictionLevels( $this->mTitle->getNamespace() ) !== [ '' ]
+                       MediaWikiServices::getInstance()->getNamespaceInfo()->getRestrictionLevels(
+                               $this->mTitle->getNamespace()
+                       ) !== [ '' ]
                ) {
                        # Is the title semi-protected?
                        if ( $this->mTitle->isSemiProtected() ) {
index 6acfda3..ff4c786 100644 (file)
@@ -191,7 +191,7 @@ class Linker {
         */
        public static function getInvalidTitleDescription( IContextSource $context, $namespace, $title ) {
                // First we check whether the namespace exists or not.
-               if ( MWNamespace::exists( $namespace ) ) {
+               if ( MediaWikiServices::getInstance()->getNamespaceInfo()->exists( $namespace ) ) {
                        if ( $namespace == NS_MAIN ) {
                                $name = $context->msg( 'blanknamespace' )->text();
                        } else {
@@ -1302,7 +1302,12 @@ class Linker {
                                ([^[]*) # 3. link trail (the text up until the next link)
                        /x',
                        function ( $match ) use ( $title, $local, $wikiId ) {
-                               $medians = '(?:' . preg_quote( MWNamespace::getCanonicalName( NS_MEDIA ), '/' ) . '|';
+                               $services = MediaWikiServices::getInstance();
+
+                               $medians = '(?:';
+                               $medians .= preg_quote(
+                                       $services->getNamespaceInfo()->getCanonicalName( NS_MEDIA ), '/' );
+                               $medians .= '|';
                                $medians .= preg_quote(
                                        MediaWikiServices::getInstance()->getContentLanguage()->getNsText( NS_MEDIA ),
                                        '/'
@@ -1410,8 +1415,9 @@ class Linker {
                                        $wikiId,
                                        $linkTarget->getNamespace() === 0
                                                ? $linkTarget->getDBkey()
-                                               : MWNamespace::getCanonicalName( $linkTarget->getNamespace() ) . ':'
-                                                       . $linkTarget->getDBkey(),
+                                               : MediaWikiServices::getInstance()->getNamespaceInfo()->
+                                                       getCanonicalName( $linkTarget->getNamespace() ) .
+                                                       ':' . $linkTarget->getDBkey(),
                                        $linkTarget->getFragment()
                                ),
                                $text,
@@ -1446,7 +1452,10 @@ class Linker {
 
                # Some namespaces don't allow subpages,
                # so only perform processing if subpages are allowed
-               if ( $contextTitle && MWNamespace::hasSubpages( $contextTitle->getNamespace() ) ) {
+               if (
+                       $contextTitle && MediaWikiServices::getInstance()->getNamespaceInfo()->
+                       hasSubpages( $contextTitle->getNamespace() )
+               ) {
                        $hash = strpos( $target, '#' );
                        if ( $hash !== false ) {
                                $suffix = substr( $target, $hash );
index e49398a..004ca07 100644 (file)
@@ -327,7 +327,8 @@ class MovePage {
                        [ 'cl_from' => $pageid ],
                        __METHOD__
                );
-               $type = MediaWikiServices::getInstance()->getNamespaceInfo()->
+               $services = MediaWikiServices::getInstance();
+               $type = $services->getNamespaceInfo()->
                        getCategoryLinkType( $this->newTitle->getNamespace() );
                foreach ( $prefixes as $prefixRow ) {
                        $prefix = $prefixRow->cl_sortkey_prefix;
@@ -428,11 +429,13 @@ class MovePage {
                # Update watchlists
                $oldtitle = $this->oldTitle->getDBkey();
                $newtitle = $this->newTitle->getDBkey();
-               $oldsnamespace = MWNamespace::getSubject( $this->oldTitle->getNamespace() );
-               $newsnamespace = MWNamespace::getSubject( $this->newTitle->getNamespace() );
+               $oldsnamespace = $services->getNamespaceInfo()->
+                       getSubject( $this->oldTitle->getNamespace() );
+               $newsnamespace = $services->getNamespaceInfo()->
+                       getSubject( $this->newTitle->getNamespace() );
                if ( $oldsnamespace != $newsnamespace || $oldtitle != $newtitle ) {
-                       $store = MediaWikiServices::getInstance()->getWatchedItemStore();
-                       $store->duplicateAllAssociatedEntries( $this->oldTitle, $this->newTitle );
+                       $services->getWatchedItemStore()->duplicateAllAssociatedEntries(
+                               $this->oldTitle, $this->newTitle );
                }
 
                // If it is a file then move it last.
index 3e91fb3..56e2370 100644 (file)
@@ -3430,8 +3430,9 @@ class OutputPage extends ContextSource {
 
                $title = $this->getTitle();
                $ns = $title->getNamespace();
-               $canonicalNamespace = MWNamespace::exists( $ns )
-                       ? MWNamespace::getCanonicalName( $ns )
+               $nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
+               $canonicalNamespace = $nsInfo->exists( $ns )
+                       ? $nsInfo->getCanonicalName( $ns )
                        : $title->getNsText();
 
                $sk = $this->getSkin();
index 7972a1e..2f10598 100644 (file)
@@ -90,7 +90,7 @@ class ProtectionForm {
         * Loads the current state of protection into the object.
         */
        function loadData() {
-               $levels = MWNamespace::getRestrictionLevels(
+               $levels = MediaWikiServices::getInstance()->getNamespaceInfo()->getRestrictionLevels(
                        $this->mTitle->getNamespace(), $this->mContext->getUser()
                );
                $this->mCascade = $this->mTitle->areRestrictionsCascading();
@@ -179,7 +179,11 @@ class ProtectionForm {
         * Main entry point for action=protect and action=unprotect
         */
        function execute() {
-               if ( MWNamespace::getRestrictionLevels( $this->mTitle->getNamespace() ) === [ '' ] ) {
+               if (
+                       MediaWikiServices::getInstance()->getNamespaceInfo()->getRestrictionLevels(
+                               $this->mTitle->getNamespace()
+                       ) === [ '' ]
+               ) {
                        throw new ErrorPageError( 'protect-badnamespace-title', 'protect-badnamespace-text' );
                }
 
@@ -581,7 +585,8 @@ class ProtectionForm {
        function buildSelector( $action, $selected ) {
                // If the form is disabled, display all relevant levels. Otherwise,
                // just show the ones this user can use.
-               $levels = MWNamespace::getRestrictionLevels( $this->mTitle->getNamespace(),
+               $levels = MediaWikiServices::getInstance()->getNamespaceInfo()->getRestrictionLevels(
+                       $this->mTitle->getNamespace(),
                        $this->disabled ? null : $this->mContext->getUser()
                );
 
index 8adb218..e97db2d 100644 (file)
@@ -68,15 +68,15 @@ class SiteStatsInit {
         * @return int
         */
        public function articles() {
-               $config = MediaWikiServices::getInstance()->getMainConfig();
+               $services = MediaWikiServices::getInstance();
 
                $tables = [ 'page' ];
                $conds = [
-                       'page_namespace' => MWNamespace::getContentNamespaces(),
+                       'page_namespace' => $services->getNamespaceInfo()->getContentNamespaces(),
                        'page_is_redirect' => 0,
                ];
 
-               if ( $config->get( 'ArticleCountMethod' ) == 'link' ) {
+               if ( $services->getMainConfig()->get( 'ArticleCountMethod' ) == 'link' ) {
                        $tables[] = 'pagelinks';
                        $conds[] = 'pl_from=page_id';
                }
index ad6c167..866f041 100644 (file)
@@ -618,7 +618,7 @@ class Title implements LinkTarget, IDBAccessObject {
                // NOTE: ideally, this would just call makeTitle() and then isValid(),
                // but presently, that means more overhead on a potential performance hotspot.
 
-               if ( !MWNamespace::exists( $ns ) ) {
+               if ( !MediaWikiServices::getInstance()->getNamespaceInfo()->exists( $ns ) ) {
                        return null;
                }
 
@@ -820,7 +820,8 @@ class Title implements LinkTarget, IDBAccessObject {
                $canonicalNamespace = false
        ) {
                if ( $canonicalNamespace ) {
-                       $namespace = MWNamespace::getCanonicalName( $ns );
+                       $namespace = MediaWikiServices::getInstance()->getNamespaceInfo()->
+                               getCanonicalName( $ns );
                } else {
                        $namespace = MediaWikiServices::getInstance()->getContentLanguage()->getNsText( $ns );
                }
@@ -862,13 +863,13 @@ class Title implements LinkTarget, IDBAccessObject {
         * @return bool
         */
        public function isValid() {
-               if ( !MWNamespace::exists( $this->mNamespace ) ) {
+               $services = MediaWikiServices::getInstance();
+               if ( !$services->getNamespaceInfo()->exists( $this->mNamespace ) ) {
                        return false;
                }
 
                try {
-                       $parser = MediaWikiServices::getInstance()->getTitleParser();
-                       $parser->parseTitle( $this->mDbkeyform, $this->mNamespace );
+                       $services->getTitleParser()->parseTitle( $this->mDbkeyform, $this->mNamespace );
                        return true;
                } catch ( MalformedTitleException $ex ) {
                        return false;
@@ -1086,7 +1087,8 @@ class Title implements LinkTarget, IDBAccessObject {
                if ( $this->isExternal() ) {
                        // This probably shouldn't even happen, except for interwiki transclusion.
                        // If possible, use the canonical name for the foreign namespace.
-                       $nsText = MWNamespace::getCanonicalName( $this->mNamespace );
+                       $nsText = MediaWikiServices::getInstance()->getNamespaceInfo()->
+                               getCanonicalName( $this->mNamespace );
                        if ( $nsText !== false ) {
                                return $nsText;
                        }
@@ -1107,8 +1109,9 @@ class Title implements LinkTarget, IDBAccessObject {
         * @return string Namespace text
         */
        public function getSubjectNsText() {
-               return MediaWikiServices::getInstance()->getContentLanguage()->
-                       getNsText( MWNamespace::getSubject( $this->mNamespace ) );
+               $services = MediaWikiServices::getInstance();
+               return $services->getContentLanguage()->
+                       getNsText( $services->getNamespaceInfo()->getSubject( $this->mNamespace ) );
        }
 
        /**
@@ -1117,20 +1120,22 @@ class Title implements LinkTarget, IDBAccessObject {
         * @return string Namespace text
         */
        public function getTalkNsText() {
-               return MediaWikiServices::getInstance()->getContentLanguage()->
-                       getNsText( MWNamespace::getTalk( $this->mNamespace ) );
+               $services = MediaWikiServices::getInstance();
+               return $services->getContentLanguage()->
+                       getNsText( $services->getNamespaceInfo()->getTalk( $this->mNamespace ) );
        }
 
        /**
         * Can this title have a corresponding talk page?
         *
-        * @see MWNamespace::hasTalkNamespace
+        * @see NamespaceInfo::hasTalkNamespace
         * @since 1.30
         *
         * @return bool True if this title either is a talk page or can have a talk page associated.
         */
        public function canHaveTalkPage() {
-               return MWNamespace::hasTalkNamespace( $this->mNamespace );
+               return MediaWikiServices::getInstance()->getNamespaceInfo()->
+                       hasTalkNamespace( $this->mNamespace );
        }
 
        /**
@@ -1148,7 +1153,8 @@ class Title implements LinkTarget, IDBAccessObject {
         * @return bool
         */
        public function isWatchable() {
-               return !$this->isExternal() && MWNamespace::isWatchable( $this->mNamespace );
+               return !$this->isExternal() && MediaWikiServices::getInstance()->getNamespaceInfo()->
+                       isWatchable( $this->mNamespace );
        }
 
        /**
@@ -1209,7 +1215,8 @@ class Title implements LinkTarget, IDBAccessObject {
         * @since 1.19
         */
        public function inNamespace( $ns ) {
-               return MWNamespace::equals( $this->mNamespace, $ns );
+               return MediaWikiServices::getInstance()->getNamespaceInfo()->
+                       equals( $this->mNamespace, $ns );
        }
 
        /**
@@ -1248,7 +1255,8 @@ class Title implements LinkTarget, IDBAccessObject {
         * @return bool
         */
        public function hasSubjectNamespace( $ns ) {
-               return MWNamespace::subjectEquals( $this->mNamespace, $ns );
+               return MediaWikiServices::getInstance()->getNamespaceInfo()->
+                       subjectEquals( $this->mNamespace, $ns );
        }
 
        /**
@@ -1259,7 +1267,8 @@ class Title implements LinkTarget, IDBAccessObject {
         * @return bool
         */
        public function isContentPage() {
-               return MWNamespace::isContent( $this->mNamespace );
+               return MediaWikiServices::getInstance()->getNamespaceInfo()->
+                       isContent( $this->mNamespace );
        }
 
        /**
@@ -1269,7 +1278,10 @@ class Title implements LinkTarget, IDBAccessObject {
         * @return bool
         */
        public function isMovable() {
-               if ( !MWNamespace::isMovable( $this->mNamespace ) || $this->isExternal() ) {
+               if (
+                       !MediaWikiServices::getInstance()->getNamespaceInfo()->
+                               isMovable( $this->mNamespace ) || $this->isExternal()
+               ) {
                        // Interwiki title or immovable namespace. Hooks don't get to override here
                        return false;
                }
@@ -1299,7 +1311,8 @@ class Title implements LinkTarget, IDBAccessObject {
         * @return bool
         */
        public function isSubpage() {
-               return MWNamespace::hasSubpages( $this->mNamespace )
+               return MediaWikiServices::getInstance()->getNamespaceInfo()->
+                       hasSubpages( $this->mNamespace )
                        ? strpos( $this->getText(), '/' ) !== false
                        : false;
        }
@@ -1495,7 +1508,8 @@ class Title implements LinkTarget, IDBAccessObject {
         * @return bool
         */
        public function isTalkPage() {
-               return MWNamespace::isTalk( $this->mNamespace );
+               return MediaWikiServices::getInstance()->getNamespaceInfo()->
+                       isTalk( $this->mNamespace );
        }
 
        /**
@@ -1724,7 +1738,10 @@ class Title implements LinkTarget, IDBAccessObject {
         * @since 1.20
         */
        public function getRootText() {
-               if ( !MWNamespace::hasSubpages( $this->mNamespace ) ) {
+               if (
+                       !MediaWikiServices::getInstance()->getNamespaceInfo()->
+                               hasSubpages( $this->mNamespace )
+               ) {
                        return $this->getText();
                }
 
@@ -1760,7 +1777,10 @@ class Title implements LinkTarget, IDBAccessObject {
         */
        public function getBaseText() {
                $text = $this->getText();
-               if ( !MWNamespace::hasSubpages( $this->mNamespace ) ) {
+               if (
+                       !MediaWikiServices::getInstance()->getNamespaceInfo()->
+                               hasSubpages( $this->mNamespace )
+               ) {
                        return $text;
                }
 
@@ -1801,7 +1821,10 @@ class Title implements LinkTarget, IDBAccessObject {
         * @return string Subpage name
         */
        public function getSubpageText() {
-               if ( !MWNamespace::hasSubpages( $this->mNamespace ) ) {
+               if (
+                       !MediaWikiServices::getInstance()->getNamespaceInfo()->
+                               hasSubpages( $this->mNamespace )
+               ) {
                        return $this->mTextform;
                }
                $parts = explode( '/', $this->mTextform );
@@ -2868,7 +2891,10 @@ class Title implements LinkTarget, IDBAccessObject {
         * @return bool
         */
        public function hasSubpages() {
-               if ( !MWNamespace::hasSubpages( $this->mNamespace ) ) {
+               if (
+                       !MediaWikiServices::getInstance()->getNamespaceInfo()->
+                               hasSubpages( $this->mNamespace )
+               ) {
                        # Duh
                        return false;
                }
@@ -2896,7 +2922,10 @@ class Title implements LinkTarget, IDBAccessObject {
         *  doesn't allow subpages
         */
        public function getSubpages( $limit = -1 ) {
-               if ( !MWNamespace::hasSubpages( $this->mNamespace ) ) {
+               if (
+                       !MediaWikiServices::getInstance()->getNamespaceInfo()->
+                               hasSubpages( $this->mNamespace )
+               ) {
                        return [];
                }
 
@@ -3130,7 +3159,8 @@ class Title implements LinkTarget, IDBAccessObject {
         * @return string Containing capitalized title
         */
        public static function capitalize( $text, $ns = NS_MAIN ) {
-               if ( MWNamespace::isCapitalized( $ns ) ) {
+               $services = MediaWikiServices::getInstance();
+               if ( $services->getNamespaceInfo()->isCapitalized( $ns ) ) {
                        return MediaWikiServices::getInstance()->getContentLanguage()->ucfirst( $text );
                } else {
                        return $text;
@@ -3472,14 +3502,15 @@ class Title implements LinkTarget, IDBAccessObject {
                        ];
                }
                // Do the source and target namespaces support subpages?
-               if ( !MWNamespace::hasSubpages( $this->mNamespace ) ) {
+               $nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
+               if ( !$nsInfo->hasSubpages( $this->mNamespace ) ) {
                        return [
-                               [ 'namespace-nosubpages', MWNamespace::getCanonicalName( $this->mNamespace ) ],
+                               [ 'namespace-nosubpages', $nsInfo->getCanonicalName( $this->mNamespace ) ],
                        ];
                }
-               if ( !MWNamespace::hasSubpages( $nt->getNamespace() ) ) {
+               if ( !$nsInfo->hasSubpages( $nt->getNamespace() ) ) {
                        return [
-                               [ 'namespace-nosubpages', MWNamespace::getCanonicalName( $nt->getNamespace() ) ],
+                               [ 'namespace-nosubpages', $nsInfo->getCanonicalName( $nt->getNamespace() ) ],
                        ];
                }
 
@@ -4293,9 +4324,10 @@ class Title implements LinkTarget, IDBAccessObject {
         */
        public function getNamespaceKey( $prepend = 'nstab-' ) {
                // Gets the subject namespace of this title
-               $subjectNS = MWNamespace::getSubject( $this->mNamespace );
+               $nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
+               $subjectNS = $nsInfo->getSubject( $this->mNamespace );
                // Prefer canonical namespace name for HTML IDs
-               $namespaceKey = MWNamespace::getCanonicalName( $subjectNS );
+               $namespaceKey = $nsInfo->getCanonicalName( $subjectNS );
                if ( $namespaceKey === false ) {
                        // Fallback to localised text
                        $namespaceKey = $this->getSubjectNsText();
@@ -4391,7 +4423,8 @@ class Title implements LinkTarget, IDBAccessObject {
        public function canUseNoindex() {
                global $wgExemptFromUserRobotsControl;
 
-               $bannedNamespaces = $wgExemptFromUserRobotsControl ?? MWNamespace::getContentNamespaces();
+               $bannedNamespaces = $wgExemptFromUserRobotsControl ??
+                       MediaWikiServices::getInstance()->getNamespaceInfo()->getContentNamespaces();
 
                return !in_array( $this->mNamespace, $bannedNamespaces );
        }
@@ -4558,7 +4591,10 @@ class Title implements LinkTarget, IDBAccessObject {
                        }
                }
 
-               if ( MWNamespace::hasSubpages( $this->mNamespace ) ) {
+               if (
+                       MediaWikiServices::getInstance()->getNamespaceInfo()->
+                               hasSubpages( $this->mNamespace )
+               ) {
                        // Optional notice for page itself and any parent page
                        $editnotice_base = $editnotice_ns;
                        foreach ( explode( '/', $this->mDbkeyform ) as $part ) {
index b3a49c7..ebdbc42 100644 (file)
@@ -19,6 +19,8 @@
  * @ingroup Categories
  */
 
+use MediaWiki\MediaWikiServices;
+
 /**
  * This class performs some operations related to tracking categories, such as creating
  * a list of all such categories.
@@ -80,6 +82,7 @@ class TrackingCategories {
                }
 
                $trackingCategories = [];
+               $nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
                foreach ( $categories as $catMsg ) {
                        /*
                         * Check if the tracking category varies by namespace
@@ -96,7 +99,7 @@ class TrackingCategories {
                        // Match things like {{NAMESPACE}} and {{NAMESPACENUMBER}}.
                        // False positives are ok, this is just an efficiency shortcut
                        if ( strpos( $msgObj->plain(), '{{' ) !== false ) {
-                               $ns = MWNamespace::getValidNamespaces();
+                               $ns = $nsInfo->getValidNamespaces();
                                foreach ( $ns as $namesp ) {
                                        $tempTitle = Title::makeTitleSafe( $namesp, $catMsg );
                                        if ( !$tempTitle ) {
index 49a6bb5..bfba59a 100644 (file)
@@ -399,7 +399,7 @@ class InfoAction extends FormlessAction {
                }
 
                // Subpages of this page, if subpages are enabled for the current NS
-               if ( MWNamespace::hasSubpages( $title->getNamespace() ) ) {
+               if ( $services->getNamespaceInfo()->hasSubpages( $title->getNamespace() ) ) {
                        $prefixIndex = SpecialPage::getTitleFor(
                                'Prefixindex', $title->getPrefixedText() . '/' );
                        $pageInfo['header-basic'][] = [
@@ -730,12 +730,13 @@ class InfoAction extends FormlessAction {
        protected function pageCounts( Page $page ) {
                $fname = __METHOD__;
                $config = $this->context->getConfig();
-               $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
+               $services = MediaWikiServices::getInstance();
+               $cache = $services->getMainWANObjectCache();
 
                return $cache->getWithSetCallback(
                        self::getCacheKey( $cache, $page->getTitle(), $page->getLatest() ),
                        WANObjectCache::TTL_WEEK,
-                       function ( $oldValue, &$ttl, &$setOpts ) use ( $page, $config, $fname ) {
+                       function ( $oldValue, &$ttl, &$setOpts ) use ( $page, $config, $fname, $services ) {
                                global $wgActorTableSchemaMigrationStage;
 
                                $title = $page->getTitle();
@@ -759,7 +760,7 @@ class InfoAction extends FormlessAction {
                                        $joins = [];
                                }
 
-                               $watchedItemStore = MediaWikiServices::getInstance()->getWatchedItemStore();
+                               $watchedItemStore = $services->getWatchedItemStore();
 
                                $result = [];
                                $result['watchers'] = $watchedItemStore->countWatchers( $title );
@@ -824,7 +825,7 @@ class InfoAction extends FormlessAction {
                                );
 
                                // Subpages (if enabled)
-                               if ( MWNamespace::hasSubpages( $title->getNamespace() ) ) {
+                               if ( $services->getNamespaceInfo()->hasSubpages( $title->getNamespace() ) ) {
                                        $conds = [ 'page_namespace' => $title->getNamespace() ];
                                        $conds[] = 'page_title ' .
                                                $dbr->buildLike( $title->getDBkey() . '/', $dbr->anyString() );
index 19d84f7..dbf72be 100644 (file)
@@ -20,6 +20,7 @@
  * @file
  */
 
+use MediaWiki\MediaWikiServices;
 use Wikimedia\Rdbms\IDatabase;
 
 /**
@@ -1198,7 +1199,8 @@ abstract class ApiBase extends ContextSource {
                        $provided = $this->getMain()->getCheck( $encParamName );
 
                        if ( isset( $value ) && $type == 'namespace' ) {
-                               $type = MWNamespace::getValidNamespaces();
+                               $type = MediaWikiServices::getInstance()->getNamespaceInfo()->
+                                       getValidNamespaces();
                                if ( isset( $paramSettings[self::PARAM_EXTRA_NAMESPACES] ) &&
                                        is_array( $paramSettings[self::PARAM_EXTRA_NAMESPACES] )
                                ) {
index 1656e7c..78efe41 100644 (file)
@@ -583,7 +583,8 @@ class ApiHelp extends ApiBase {
                                                                        break;
 
                                                                case 'namespace':
-                                                                       $namespaces = MWNamespace::getValidNamespaces();
+                                                                       $namespaces = MediaWikiServices::getInstance()->
+                                                                               getNamespaceInfo()->getValidNamespaces();
                                                                        if ( isset( $settings[ApiBase::PARAM_EXTRA_NAMESPACES] ) &&
                                                                                is_array( $settings[ApiBase::PARAM_EXTRA_NAMESPACES] )
                                                                        ) {
index b321c7d..64c6f45 100644 (file)
@@ -866,6 +866,8 @@ class ApiPageSet extends ApiBase {
                        ApiBase::dieDebug( __METHOD__, 'Missing $processTitles parameter when $remaining is provided' );
                }
 
+               $nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
+
                $usernames = [];
                if ( $res ) {
                        foreach ( $res as $row ) {
@@ -884,7 +886,7 @@ class ApiPageSet extends ApiBase {
                                $this->processDbRow( $row );
 
                                // Need gender information
-                               if ( MWNamespace::hasGenderDistinction( $row->page_namespace ) ) {
+                               if ( $nsInfo->hasGenderDistinction( $row->page_namespace ) ) {
                                        $usernames[] = $row->page_title;
                                }
                        }
@@ -907,7 +909,7 @@ class ApiPageSet extends ApiBase {
                                                $this->mTitles[] = $title;
 
                                                // need gender information
-                                               if ( MWNamespace::hasGenderDistinction( $ns ) ) {
+                                               if ( $nsInfo->hasGenderDistinction( $ns ) ) {
                                                        $usernames[] = $dbkey;
                                                }
                                        }
@@ -1249,7 +1251,10 @@ class ApiPageSet extends ApiBase {
                        }
 
                        // Need gender information
-                       if ( MWNamespace::hasGenderDistinction( $titleObj->getNamespace() ) ) {
+                       if (
+                               MediaWikiServices::getInstance()->getNamespaceInfo()->
+                                       hasGenderDistinction( $titleObj->getNamespace() )
+                       ) {
                                $usernames[] = $titleObj->getText();
                        }
                }
index bb50185..beaad43 100644 (file)
@@ -49,7 +49,8 @@ class ApiQueryAllDeletedRevisions extends ApiQueryRevisionsBase {
                $user = $this->getUser();
                $db = $this->getDB();
                $params = $this->extractRequestParams( false );
-               $revisionStore = MediaWikiServices::getInstance()->getRevisionStore();
+               $services = MediaWikiServices::getInstance();
+               $revisionStore = $services->getRevisionStore();
 
                $result = $this->getResult();
 
@@ -156,7 +157,8 @@ class ApiQueryAllDeletedRevisions extends ApiQueryRevisionsBase {
                $miser_ns = null;
 
                if ( $mode == 'all' ) {
-                       $namespaces = $params['namespace'] ?? MWNamespace::getValidNamespaces();
+                       $namespaces = $params['namespace'] ??
+                               $services->getNamespaceInfo()->getValidNamespaces();
                        $this->addWhereFld( 'ar_namespace', $namespaces );
 
                        // For from/to/prefix, we have to consider the potential
index 1940600..08f3ea3 100644 (file)
@@ -211,12 +211,13 @@ class ApiQueryAllPages extends ApiQueryGeneratorBase {
                $res = $this->select( __METHOD__ );
 
                // Get gender information
-               if ( MWNamespace::hasGenderDistinction( $params['namespace'] ) ) {
+               $services = MediaWikiServices::getInstance();
+               if ( $services->getNamespaceInfo()->hasGenderDistinction( $params['namespace'] ) ) {
                        $users = [];
                        foreach ( $res as $row ) {
                                $users[] = $row->page_title;
                        }
-                       MediaWikiServices::getInstance()->getGenderCache()->doQuery( $users, __METHOD__ );
+                       $services->getGenderCache()->doQuery( $users, __METHOD__ );
                        $res->rewind(); // reset
                }
 
index 58445a1..050bc0f 100644 (file)
@@ -44,7 +44,8 @@ class ApiQueryAllRevisions extends ApiQueryRevisionsBase {
 
                $db = $this->getDB();
                $params = $this->extractRequestParams( false );
-               $revisionStore = MediaWikiServices::getInstance()->getRevisionStore();
+               $services = MediaWikiServices::getInstance();
+               $revisionStore = $services->getRevisionStore();
 
                $result = $this->getResult();
 
@@ -70,7 +71,7 @@ class ApiQueryAllRevisions extends ApiQueryRevisionsBase {
                if ( $params['namespace'] !== null ) {
                        $params['namespace'] = array_unique( $params['namespace'] );
                        sort( $params['namespace'] );
-                       if ( $params['namespace'] != MWNamespace::getValidNamespaces() ) {
+                       if ( $params['namespace'] != $services->getNamespaceInfo()->getValidNamespaces() ) {
                                $needPageTable = true;
                                if ( $this->getConfig()->get( 'MiserMode' ) ) {
                                        $miser_ns = $params['namespace'];
index a5437ba..276aafb 100644 (file)
@@ -708,10 +708,11 @@ class ApiQueryInfo extends ApiQueryBase {
         */
        private function getTSIDs() {
                $getTitles = $this->talkids = $this->subjectids = [];
+               $nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
 
                /** @var Title $t */
                foreach ( $this->everything as $t ) {
-                       if ( MWNamespace::isTalk( $t->getNamespace() ) ) {
+                       if ( $nsInfo->isTalk( $t->getNamespace() ) ) {
                                if ( $this->fld_subjectid ) {
                                        $getTitles[] = $t->getSubjectPage();
                                }
@@ -734,12 +735,12 @@ class ApiQueryInfo extends ApiQueryBase {
                $this->addWhere( $lb->constructSet( 'page', $db ) );
                $res = $this->select( __METHOD__ );
                foreach ( $res as $row ) {
-                       if ( MWNamespace::isTalk( $row->page_namespace ) ) {
-                               $this->talkids[MWNamespace::getSubject( $row->page_namespace )][$row->page_title] =
-                                       (int)$row->page_id;
+                       if ( $nsInfo->isTalk( $row->page_namespace ) ) {
+                               $this->talkids[$nsInfo->getSubject( $row->page_namespace )][$row->page_title] =
+                                       (int)( $row->page_id );
                        } else {
-                               $this->subjectids[MWNamespace::getTalk( $row->page_namespace )][$row->page_title] =
-                                       (int)$row->page_id;
+                               $this->subjectids[$nsInfo->getTalk( $row->page_namespace )][$row->page_title] =
+                                       (int)( $row->page_id );
                        }
                }
        }
index 68ab725..7e4a891 100644 (file)
@@ -282,27 +282,28 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                $data = [
                        ApiResult::META_TYPE => 'assoc',
                ];
+               $nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
                foreach (
                        MediaWikiServices::getInstance()->getContentLanguage()->getFormattedNamespaces()
                        as $ns => $title
                ) {
                        $data[$ns] = [
                                'id' => (int)$ns,
-                               'case' => MWNamespace::isCapitalized( $ns ) ? 'first-letter' : 'case-sensitive',
+                               'case' => $nsInfo->isCapitalized( $ns ) ? 'first-letter' : 'case-sensitive',
                        ];
                        ApiResult::setContentValue( $data[$ns], 'name', $title );
-                       $canonical = MWNamespace::getCanonicalName( $ns );
+                       $canonical = $nsInfo->getCanonicalName( $ns );
 
-                       $data[$ns]['subpages'] = MWNamespace::hasSubpages( $ns );
+                       $data[$ns]['subpages'] = $nsInfo->hasSubpages( $ns );
 
                        if ( $canonical ) {
                                $data[$ns]['canonical'] = strtr( $canonical, '_', ' ' );
                        }
 
-                       $data[$ns]['content'] = MWNamespace::isContent( $ns );
-                       $data[$ns]['nonincludable'] = MWNamespace::isNonincludable( $ns );
+                       $data[$ns]['content'] = $nsInfo->isContent( $ns );
+                       $data[$ns]['nonincludable'] = $nsInfo->isNonincludable( $ns );
 
-                       $contentmodel = MWNamespace::getNamespaceContentModel( $ns );
+                       $contentmodel = $nsInfo->getNamespaceContentModel( $ns );
                        if ( $contentmodel ) {
                                $data[$ns]['defaultcontentmodel'] = $contentmodel;
                        }
index 4d00fbc..bb9114a 100644 (file)
@@ -20,6 +20,8 @@
  * @file
  */
 
+use MediaWiki\MediaWikiServices;
+
 /**
  * Feed to Special:RecentChanges and Special:RecentChangesLinked.
  *
@@ -88,9 +90,10 @@ class ChangesFeed {
                        }
                }
 
+               $nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
                foreach ( $sorted as $obj ) {
                        $title = Title::makeTitle( $obj->rc_namespace, $obj->rc_title );
-                       $talkpage = MWNamespace::hasTalkNamespace( $obj->rc_namespace )
+                       $talkpage = $nsInfo->hasTalkNamespace( $obj->rc_namespace )
                                ? $title->getTalkPage()->getFullURL()
                                : '';
 
index decbb0c..cc73dd2 100644 (file)
@@ -1,4 +1,5 @@
 <?php
+
 /**
  * Base class for content handling.
  *
index 354cc61..103b3e5 100644 (file)
@@ -24,7 +24,7 @@
 
 namespace MediaWiki\EditPage;
 
-use MWNamespace;
+use MediaWiki\MediaWikiServices;
 use Sanitizer;
 use Title;
 use User;
@@ -75,7 +75,8 @@ class TextboxBuilder {
        public function getTextboxProtectionCSSClasses( Title $title ) {
                $classes = []; // Textarea CSS
                if ( $title->isProtected( 'edit' ) &&
-                       MWNamespace::getRestrictionLevels( $title->getNamespace() ) !== [ '' ]
+                       MediaWikiServices::getInstance()->getNamespaceInfo()->
+                       getRestrictionLevels( $title->getNamespace() ) !== [ '' ]
                ) {
                        # Is the title semi-protected?
                        if ( $title->isSemiProtected() ) {
index c201c76..6b2a22a 100644 (file)
@@ -23,6 +23,8 @@
  * @file
  */
 
+use MediaWiki\MediaWikiServices;
+
 /**
  * @ingroup Dump
  */
@@ -32,6 +34,7 @@ class DumpNotalkFilter extends DumpFilter {
         * @return bool
         */
        protected function pass( $page ) {
-               return !MWNamespace::isTalk( $page->page_namespace );
+               return !MediaWikiServices::getInstance()->getNamespaceInfo()->
+                       isTalk( $page->page_namespace );
        }
 }
index 54249a8..39153cf 100644 (file)
@@ -141,6 +141,7 @@ class XmlDumpWriter {
         */
        function namespaces() {
                $spaces = "<namespaces>\n";
+               $nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
                foreach (
                        MediaWikiServices::getInstance()->getContentLanguage()->getFormattedNamespaces()
                        as $ns => $title
@@ -149,7 +150,8 @@ class XmlDumpWriter {
                                Xml::element( 'namespace',
                                        [
                                                'key' => $ns,
-                                               'case' => MWNamespace::isCapitalized( $ns ) ? 'first-letter' : 'case-sensitive',
+                                               'case' => $nsInfo->isCapitalized( $ns )
+                                                       ? 'first-letter' : 'case-sensitive',
                                        ], $title ) . "\n";
                }
                $spaces .= "    </namespaces>";
index 3a366c8..3e11a48 100644 (file)
@@ -176,7 +176,8 @@ class FileRepo {
                }
 
                // Optional settings that have a default
-               $this->initialCapital = $info['initialCapital'] ?? MWNamespace::isCapitalized( NS_FILE );
+               $this->initialCapital = $info['initialCapital'] ??
+                       MediaWikiServices::getInstance()->getNamespaceInfo()->isCapitalized( NS_FILE );
                $this->url = $info['url'] ?? false; // a subclass may set the URL (e.g. ForeignAPIRepo)
                if ( isset( $info['thumbUrl'] ) ) {
                        $this->thumbUrl = $info['thumbUrl'];
@@ -645,7 +646,10 @@ class FileRepo {
         * @return string
         */
        public function getNameFromTitle( Title $title ) {
-               if ( $this->initialCapital != MWNamespace::isCapitalized( NS_FILE ) ) {
+               if (
+                       $this->initialCapital !=
+                       MediaWikiServices::getInstance()->getNamespaceInfo()->isCapitalized( NS_FILE )
+               ) {
                        $name = $title->getUserCaseDBKey();
                        if ( $this->initialCapital ) {
                                $name = MediaWikiServices::getInstance()->getContentLanguage()->ucfirst( $name );
index 9de7eb8..4d5222c 100644 (file)
@@ -169,7 +169,8 @@ class TraditionalImageGallery extends ImageGalleryBase {
 
                        // @todo Code is incomplete.
                        // $linkTarget = Title::newFromText( MediaWikiServices::getInstance()->
-                       // getContentLanguage()->getNsText( MWNamespace::getUser() ) . ":{$ut}" );
+                       // getContentLanguage()->getNsText( MediaWikiServices::getInstance()->
+                       // getNamespaceInfo()->getUser() ) . ":{$ut}" );
                        // $ul = Linker::link( $linkTarget, $ut );
 
                        $meta = [];
index 466e3d8..8f58344 100644 (file)
@@ -257,7 +257,7 @@ class WikiImporter {
                        return true;
                } elseif (
                        $namespace >= 0 &&
-                       MWNamespace::exists( intval( $namespace ) )
+                       MediaWikiServices::getInstance()->getNamespaceInfo()->exists( intval( $namespace ) )
                ) {
                        $namespace = intval( $namespace );
                        $this->setImportTitleFactory( new NamespaceImportTitleFactory( $namespace ) );
@@ -283,7 +283,10 @@ class WikiImporter {
 
                        if ( !$title || $title->isExternal() ) {
                                $status->fatal( 'import-rootpage-invalid' );
-                       } elseif ( !MWNamespace::hasSubpages( $title->getNamespace() ) ) {
+                       } elseif (
+                               !MediaWikiServices::getInstance()->getNamespaceInfo()->
+                               hasSubpages( $title->getNamespace() )
+                       ) {
                                $displayNSText = $title->getNamespace() == NS_MAIN
                                        ? wfMessage( 'blanknamespace' )->text()
                                        : MediaWikiServices::getInstance()->getContentLanguage()->
index 124437e..b20c83e 100644 (file)
@@ -1352,6 +1352,8 @@ class Article implements Page {
 
                $title = $this->getTitle();
 
+               $services = MediaWikiServices::getInstance();
+
                # Show info in user (talk) namespace. Does the user exist? Is he blocked?
                if ( $title->getNamespace() == NS_USER
                        || $title->getNamespace() == NS_USER_TALK
@@ -1374,7 +1376,8 @@ class Article implements Page {
                                LogEventsList::showLogExtract(
                                        $outputPage,
                                        'block',
-                                       MWNamespace::getCanonicalName( NS_USER ) . ':' . $block->getTarget(),
+                                       $services->getNamespaceInfo()->getCanonicalName( NS_USER ) . ':' .
+                                               $block->getTarget(),
                                        '',
                                        [
                                                'lim' => 1,
@@ -1396,7 +1399,7 @@ class Article implements Page {
                # Show delete and move logs if there were any such events.
                # The logging query can DOS the site when bots/crawlers cause 404 floods,
                # so be careful showing this. 404 pages must be cheap as they are hard to cache.
-               $cache = MediaWikiServices::getInstance()->getMainObjectStash();
+               $cache = $services->getMainObjectStash();
                $key = $cache->makeKey( 'page-recent-delete', md5( $title->getPrefixedText() ) );
                $loggedIn = $this->getContext()->getUser()->isLoggedIn();
                $sessionExists = $this->getContext()->getRequest()->getSession()->isPersistent();
index 69a6f5f..8cbde09 100644 (file)
@@ -57,9 +57,10 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
                $contLang = MediaWikiServices::getInstance()->getContentLanguage();
                $namespaceIds = $contLang->getNamespaceIds();
                $caseSensitiveNamespaces = [];
-               foreach ( MWNamespace::getCanonicalNamespaces() as $index => $name ) {
+               $nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
+               foreach ( $nsInfo->getCanonicalNamespaces() as $index => $name ) {
                        $namespaceIds[$contLang->lc( $name )] = $index;
-                       if ( !MWNamespace::isCapitalized( $index ) ) {
+                       if ( !$nsInfo->isCapitalized( $index ) ) {
                                $caseSensitiveNamespaces[] = $index;
                        }
                }
@@ -92,7 +93,7 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
                        'wgEnableWriteAPI' => true, // Deprecated since MW 1.32
                        'wgFormattedNamespaces' => $contLang->getFormattedNamespaces(),
                        'wgNamespaceIds' => $namespaceIds,
-                       'wgContentNamespaces' => MWNamespace::getContentNamespaces(),
+                       'wgContentNamespaces' => $nsInfo->getContentNamespaces(),
                        'wgSiteName' => $conf->get( 'Sitename' ),
                        'wgDBname' => $conf->get( 'DBname' ),
                        'wgExtraSignatureNamespaces' => $conf->get( 'ExtraSignatureNamespaces' ),
index ac41c46..420c4cb 100644 (file)
@@ -755,7 +755,10 @@ abstract class Skin extends ContextSource {
                        return $subpages;
                }
 
-               if ( $out->isArticle() && MWNamespace::hasSubpages( $title->getNamespace() ) ) {
+               if (
+                       $out->isArticle() && MediaWikiServices::getInstance()->getNamespaceInfo()->
+                               hasSubpages( $title->getNamespace() )
+               ) {
                        $ptext = $title->getPrefixedText();
                        if ( strpos( $ptext, '/' ) !== false ) {
                                $links = explode( '/', $ptext );
index 25771bc..ef45d15 100644 (file)
@@ -790,7 +790,8 @@ class SkinTemplate extends Skin {
                        }
                }
 
-               $linkClass = MediaWikiServices::getInstance()->getLinkRenderer()->getLinkClasses( $title );
+               $services = MediaWikiServices::getInstance();
+               $linkClass = $services->getLinkRenderer()->getLinkClasses( $title );
 
                // wfMessageFallback will nicely accept $message as an array of fallbacks
                // or just a single key
@@ -802,8 +803,9 @@ class SkinTemplate extends Skin {
                if ( $msg->exists() ) {
                        $text = $msg->text();
                } else {
-                       $text = MediaWikiServices::getInstance()->getContentLanguage()->getConverter()->
-                               convertNamespace( MWNamespace::getSubject( $title->getNamespace() ) );
+                       $text = $services->getContentLanguage()->getConverter()->
+                               convertNamespace( $services->getNamespaceInfo()->
+                                       getSubject( $title->getNamespace() ) );
                }
 
                // Avoid PHP 7.1 warning of passing $this by reference
@@ -1086,7 +1088,8 @@ class SkinTemplate extends Skin {
                                }
 
                                if ( $title->quickUserCan( 'protect', $user ) && $title->getRestrictionTypes() &&
-                                       MWNamespace::getRestrictionLevels( $title->getNamespace(), $user ) !== [ '' ]
+                                       MediaWikiServices::getInstance()->getNamespaceInfo()->
+                                               getRestrictionLevels( $title->getNamespace(), $user ) !== [ '' ]
                                ) {
                                        $mode = $title->isProtected() ? 'unprotect' : 'protect';
                                        $content_navigation['actions'][$mode] = [
index dee31b2..f4b574b 100644 (file)
  * @file
  * @ingroup SpecialPage
  */
+
 use MediaWiki\Logger\LoggerFactory;
+use MediaWiki\MediaWikiServices;
 use Wikimedia\Rdbms\DBQueryTimeoutError;
 use Wikimedia\Rdbms\IResultWrapper;
 use Wikimedia\Rdbms\FakeResultWrapper;
 use Wikimedia\Rdbms\IDatabase;
-use MediaWiki\MediaWikiServices;
 
 /**
  * Special page which uses a ChangesList to show query results.
@@ -1451,7 +1452,8 @@ abstract class ChangesListSpecialPage extends SpecialPage {
                        if ( $opts[ 'associated' ] ) {
                                $associatedNamespaces = array_map(
                                        function ( $ns ) {
-                                               return MWNamespace::getAssociated( $ns );
+                                               return MediaWikiServices::getInstance()->getNamespaceInfo()->
+                                                       getAssociated( $ns );
                                        },
                                        $namespaces
                                );
index cea6d37..a32393e 100644 (file)
@@ -45,7 +45,8 @@ class AncientPagesPage extends QueryPage {
        public function getQueryInfo() {
                $tables = [ 'page', 'revision' ];
                $conds = [
-                       'page_namespace' => MWNamespace::getContentNamespaces(),
+                       'page_namespace' =>
+                               MediaWikiServices::getInstance()->getNamespaceInfo()->getContentNamespaces(),
                        'page_is_redirect' => 0
                ];
                $joinConds = [
index dc4d1bd..ce08392 100644 (file)
@@ -21,6 +21,7 @@
  * @ingroup SpecialPage
  */
 
+use MediaWiki\MediaWikiServices;
 use MediaWiki\Widget\DateInputWidget;
 
 /**
@@ -328,7 +329,8 @@ class SpecialContributions extends IncludableSpecialPage {
 
                                if ( !is_null( $block ) && $block->getType() != Block::TYPE_AUTO ) {
                                        if ( $block->getType() == Block::TYPE_RANGE ) {
-                                               $nt = MWNamespace::getCanonicalName( NS_USER ) . ':' . $block->getTarget();
+                                               $nt = MediaWikiServices::getInstance()->getNamespaceInfo()->
+                                                       getCanonicalName( NS_USER ) . ':' . $block->getTarget();
                                        }
 
                                        $out = $this->getOutput(); // showLogExtract() wants first parameter by reference
index f13f231..2a967c5 100644 (file)
@@ -21,6 +21,8 @@
  * @ingroup SpecialPage
  */
 
+use MediaWiki\MediaWikiServices;
+
 /**
  * A special page that list pages that contain no link to other pages
  *
@@ -66,7 +68,8 @@ class DeadendPagesPage extends PageQueryPage {
                        ],
                        'conds' => [
                                'pl_from IS NULL',
-                               'page_namespace' => MWNamespace::getContentNamespaces(),
+                               'page_namespace' => MediaWikiServices::getInstance()->getNamespaceInfo()->
+                                       getContentNamespaces(),
                                'page_is_redirect' => 0
                        ],
                        'join_conds' => [
@@ -81,7 +84,9 @@ class DeadendPagesPage extends PageQueryPage {
        function getOrderFields() {
                // For some crazy reason ordering by a constant
                // causes a filesort
-               if ( count( MWNamespace::getContentNamespaces() ) > 1 ) {
+               if ( count( MediaWikiServices::getInstance()->getNamespaceInfo()->
+                       getContentNamespaces() ) > 1
+               ) {
                        return [ 'page_namespace', 'page_title' ];
                } else {
                        return [ 'page_title' ];
index 65cf79e..73b438c 100644 (file)
@@ -21,6 +21,8 @@
  * @ingroup SpecialPage
  */
 
+use MediaWiki\MediaWikiServices;
+
 /**
  * Implements Special:DeletedContributions to display archived revisions
  * @ingroup SpecialPage
@@ -160,7 +162,8 @@ class DeletedContributionsPage extends SpecialPage {
                        $block = Block::newFromTarget( $userObj, $userObj );
                        if ( !is_null( $block ) && $block->getType() != Block::TYPE_AUTO ) {
                                if ( $block->getType() == Block::TYPE_RANGE ) {
-                                       $nt = MWNamespace::getCanonicalName( NS_USER ) . ':' . $block->getTarget();
+                                       $nt = MediaWikiServices::getInstance()->getNamespaceInfo()->
+                                               getCanonicalName( NS_USER ) . ':' . $block->getTarget();
                                }
 
                                // LogEventsList::showLogExtract() wants the first parameter by ref
index b05c81a..480e81a 100644 (file)
@@ -380,8 +380,9 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
         */
        protected function getWatchlistInfo() {
                $titles = [];
+               $services = MediaWikiServices::getInstance();
 
-               $watchedItems = MediaWikiServices::getInstance()->getWatchedItemStore()
+               $watchedItems = $services->getWatchedItemStore()
                        ->getWatchedItemsForUser( $this->getUser(), [ 'sort' => WatchedItemStore::SORT_ASC ] );
 
                $lb = new LinkBatch();
@@ -390,7 +391,7 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
                        $namespace = $watchedItem->getLinkTarget()->getNamespace();
                        $dbKey = $watchedItem->getLinkTarget()->getDBkey();
                        $lb->add( $namespace, $dbKey );
-                       if ( !MWNamespace::isTalk( $namespace ) ) {
+                       if ( !$services->getNamespaceInfo()->isTalk( $namespace ) ) {
                                $titles[$namespace][$dbKey] = 1;
                        }
                }
@@ -511,6 +512,7 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
         */
        private function getExpandedTargets( array $targets ) {
                $expandedTargets = [];
+               $services = MediaWikiServices::getInstance();
                foreach ( $targets as $target ) {
                        if ( !$target instanceof LinkTarget ) {
                                try {
@@ -523,8 +525,10 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
 
                        $ns = $target->getNamespace();
                        $dbKey = $target->getDBkey();
-                       $expandedTargets[] = new TitleValue( MWNamespace::getSubject( $ns ), $dbKey );
-                       $expandedTargets[] = new TitleValue( MWNamespace::getTalk( $ns ), $dbKey );
+                       $expandedTargets[] =
+                               new TitleValue( $services->getNamespaceInfo()->getSubject( $ns ), $dbKey );
+                       $expandedTargets[] =
+                               new TitleValue( $services->getNamespaceInfo()->getTalk( $ns ), $dbKey );
                }
                return $expandedTargets;
        }
index 84454e2..c47d87b 100644 (file)
@@ -52,7 +52,8 @@ class FewestrevisionsPage extends QueryPage {
                                'redirect' => 'page_is_redirect'
                        ],
                        'conds' => [
-                               'page_namespace' => MWNamespace::getContentNamespaces(),
+                               'page_namespace' => MediaWikiServices::getInstance()->getNamespaceInfo()->
+                                       getContentNamespaces(),
                                'page_id = rev_page' ],
                        'options' => [
                                'GROUP BY' => [ 'page_namespace', 'page_title', 'page_is_redirect' ]
index 1d10791..ae4b090 100644 (file)
@@ -84,7 +84,8 @@ class SpecialListGroupRights extends SpecialPage {
                        $groupnameLocalized = UserGroupMembership::getGroupName( $groupname );
 
                        $grouppageLocalizedTitle = UserGroupMembership::getGroupPage( $groupname )
-                               ?: Title::newFromText( MWNamespace::getCanonicalName( NS_PROJECT ) . ':' . $groupname );
+                               ?: Title::newFromText( MediaWikiServices::getInstance()->getNamespaceInfo()->
+                               getCanonicalName( NS_PROJECT ) . ':' . $groupname );
 
                        if ( $group == '*' || !$grouppageLocalizedTitle ) {
                                // Do not make a link for the generic * group or group with invalid group page
@@ -162,7 +163,8 @@ class SpecialListGroupRights extends SpecialPage {
                );
                $linkRenderer = $this->getLinkRenderer();
                ksort( $namespaceProtection );
-               $validNamespaces = MWNamespace::getValidNamespaces();
+               $validNamespaces =
+                       MediaWikiServices::getInstance()->getNamespaceInfo()->getValidNamespaces();
                $contLang = MediaWikiServices::getInstance()->getContentLanguage();
                foreach ( $namespaceProtection as $namespace => $rights ) {
                        if ( !in_array( $namespace, $validNamespaces ) ) {
index ff76a4b..ca3f4da 100644 (file)
@@ -21,6 +21,8 @@
  * @ingroup SpecialPage
  */
 
+use MediaWiki\MediaWikiServices;
+
 /**
  * A special page looking for articles with no article linking to them,
  * thus being lonely.
@@ -52,7 +54,8 @@ class LonelyPagesPage extends PageQueryPage {
                $tables = [ 'page', 'pagelinks', 'templatelinks' ];
                $conds = [
                        'pl_namespace IS NULL',
-                       'page_namespace' => MWNamespace::getContentNamespaces(),
+                       'page_namespace' => MediaWikiServices::getInstance()->getNamespaceInfo()->
+                               getContentNamespaces(),
                        'page_is_redirect' => 0,
                        'tl_namespace IS NULL'
                ];
@@ -89,7 +92,9 @@ class LonelyPagesPage extends PageQueryPage {
        function getOrderFields() {
                // For some crazy reason ordering by a constant
                // causes a filesort in MySQL 5
-               if ( count( MWNamespace::getContentNamespaces() ) > 1 ) {
+               if ( count( MediaWikiServices::getInstance()->getNamespaceInfo()->
+                       getContentNamespaces() ) > 1
+               ) {
                        return [ 'page_namespace', 'page_title' ];
                } else {
                        return [ 'page_title' ];
index 123c174..0dd9437 100644 (file)
@@ -24,6 +24,7 @@
  * @author Ã†var Arnfjörð Bjarmason <avarab@gmail.com>
  */
 
+use MediaWiki\MediaWikiServices;
 use Wikimedia\Rdbms\IResultWrapper;
 use Wikimedia\Rdbms\IDatabase;
 
@@ -53,7 +54,8 @@ class MostcategoriesPage extends QueryPage {
                                'title' => 'page_title',
                                'value' => 'COUNT(*)'
                        ],
-                       'conds' => [ 'page_namespace' => MWNamespace::getContentNamespaces() ],
+                       'conds' => [ 'page_namespace' =>
+                               MediaWikiServices::getInstance()->getNamespaceInfo()->getContentNamespaces() ],
                        'options' => [
                                'HAVING' => 'COUNT(*) > 1',
                                'GROUP BY' => [ 'page_namespace', 'page_title' ]
index c963838..0fcf842 100644 (file)
@@ -21,6 +21,7 @@
  * @ingroup SpecialPage
  */
 
+use MediaWiki\MediaWikiServices;
 use Wikimedia\Rdbms\IResultWrapper;
 use Wikimedia\Rdbms\IDatabase;
 
@@ -52,7 +53,8 @@ class MostinterwikisPage extends QueryPage {
                                'title' => 'page_title',
                                'value' => 'COUNT(*)'
                        ], 'conds' => [
-                               'page_namespace' => MWNamespace::getContentNamespaces()
+                               'page_namespace' =>
+                                       MediaWikiServices::getInstance()->getNamespaceInfo()->getContentNamespaces()
                        ], 'options' => [
                                'HAVING' => 'COUNT(*) > 1',
                                'GROUP BY' => [
index 39976c0..b561e5b 100644 (file)
@@ -21,6 +21,8 @@
  * @ingroup SpecialPage
  */
 
+use MediaWiki\MediaWikiServices;
+
 /**
  * A special page that allows users to change page titles
  *
@@ -297,7 +299,7 @@ class MovePageForm extends UnlistedSpecialPage {
 
                $immovableNamespaces = [];
                foreach ( array_keys( $this->getLanguage()->getNamespaces() ) as $nsId ) {
-                       if ( !MWNamespace::isMovable( $nsId ) ) {
+                       if ( !MediaWikiServices::getInstance()->getNamespaceInfo()->isMovable( $nsId ) ) {
                                $immovableNamespaces[] = $nsId;
                        }
                }
@@ -664,11 +666,12 @@ class MovePageForm extends UnlistedSpecialPage {
                 */
 
                // @todo FIXME: Use Title::moveSubpages() here
+               $nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
                $dbr = wfGetDB( DB_MASTER );
                if ( $this->moveSubpages && (
-                       MWNamespace::hasSubpages( $nt->getNamespace() ) || (
+                       $nsInfo->hasSubpages( $nt->getNamespace() ) || (
                                $this->moveTalk
-                                       && MWNamespace::hasSubpages( $nt->getTalkPage()->getNamespace() )
+                                       && $nsInfo->hasSubpages( $nt->getTalkPage()->getNamespace() )
                        )
                ) ) {
                        $conds = [
@@ -676,11 +679,11 @@ class MovePageForm extends UnlistedSpecialPage {
                                        . ' OR page_title = ' . $dbr->addQuotes( $ot->getDBkey() )
                        ];
                        $conds['page_namespace'] = [];
-                       if ( MWNamespace::hasSubpages( $nt->getNamespace() ) ) {
+                       if ( $nsInfo->hasSubpages( $nt->getNamespace() ) ) {
                                $conds['page_namespace'][] = $ot->getNamespace();
                        }
                        if ( $this->moveTalk &&
-                               MWNamespace::hasSubpages( $nt->getTalkPage()->getNamespace() )
+                               $nsInfo->hasSubpages( $nt->getTalkPage()->getNamespace() )
                        ) {
                                $conds['page_namespace'][] = $ot->getTalkPage()->getNamespace();
                        }
@@ -799,7 +802,8 @@ class MovePageForm extends UnlistedSpecialPage {
         * @param Title $title Page being moved.
         */
        function showSubpages( $title ) {
-               $nsHasSubpages = MWNamespace::hasSubpages( $title->getNamespace() );
+               $nsHasSubpages = MediaWikiServices::getInstance()->getNamespaceInfo()->
+                       hasSubpages( $title->getNamespace() );
                $subpages = $title->getSubpages();
                $count = $subpages instanceof TitleArray ? $subpages->count() : 0;
 
index d09deab..9bd855a 100644 (file)
@@ -21,6 +21,8 @@
  * @ingroup SpecialPage
  */
 
+use MediaWiki\MediaWikiServices;
+
 /**
  * This special page lists the defined password policies for user groups.
  * See also @ref $wgPasswordPolicy.
@@ -84,7 +86,8 @@ class SpecialPasswordPolicies extends SpecialPage {
                        $groupnameLocalized = UserGroupMembership::getGroupName( $group );
 
                        $grouppageLocalizedTitle = UserGroupMembership::getGroupPage( $group )
-                               ?: Title::newFromText( MWNamespace::getCanonicalName( NS_PROJECT ) . ':' . $group );
+                               ?: Title::newFromText( MediaWikiServices::getInstance()->getNamespaceInfo()->
+                                       getCanonicalName( NS_PROJECT ) . ':' . $group );
 
                        $grouppage = $linkRenderer->makeLink(
                                $grouppageLocalizedTitle,
index 7e5a73f..c4ea005 100644 (file)
@@ -35,7 +35,8 @@ class RandomPage extends SpecialPage {
        protected $extra = []; // Extra SQL statements
 
        public function __construct( $name = 'Randompage' ) {
-               $this->namespaces = MWNamespace::getContentNamespaces();
+               $this->namespaces = MediaWikiServices::getInstance()->getNamespaceInfo()->
+                       getContentNamespaces();
                parent::__construct( $name );
        }
 
index c88fb27..4adc247 100644 (file)
@@ -647,7 +647,9 @@ class SpecialSearch extends SpecialPage {
                ) {
                        // Reset namespace preferences: namespaces are not searched
                        // when they're not mentioned in the URL parameters.
-                       foreach ( MWNamespace::getValidNamespaces() as $n ) {
+                       foreach ( MediaWikiServices::getInstance()->getNamespaceInfo()->getValidNamespaces()
+                               as $n
+                       ) {
                                $user->setOption( 'searchNs' . $n, false );
                        }
                        // The request parameters include all the namespaces to be searched.
index d90f72c..94da25d 100644 (file)
@@ -21,6 +21,7 @@
  * @ingroup SpecialPage
  */
 
+use MediaWiki\MediaWikiServices;
 use Wikimedia\Rdbms\IResultWrapper;
 use Wikimedia\Rdbms\IDatabase;
 
@@ -45,7 +46,10 @@ class ShortPagesPage extends QueryPage {
                $blacklist = $config->get( 'ShortPagesNamespaceBlacklist' );
                $tables = [ 'page' ];
                $conds = [
-                       'page_namespace' => array_diff( MWNamespace::getContentNamespaces(), $blacklist ),
+                       'page_namespace' => array_diff(
+                               MediaWikiServices::getInstance()->getNamespaceInfo()->getContentNamespaces(),
+                               $blacklist
+                       ),
                        'page_is_redirect' => 0
                ];
                $joinConds = [];
index d5e14d2..eff8889 100644 (file)
@@ -21,6 +21,8 @@
  * @ingroup SpecialPage
  */
 
+use MediaWiki\MediaWikiServices;
+
 /**
  * Special page lists various statistics, including the contents of
  * `site_stats`, plus page view details if enabled
@@ -207,8 +209,8 @@ class SpecialStatistics extends SpecialPage {
                        }
                        $msg = $this->msg( 'grouppage-' . $groupname )->inContentLanguage();
                        if ( $msg->isBlank() ) {
-                               $grouppageLocalized = MWNamespace::getCanonicalName( NS_PROJECT ) .
-                                       ':' . $groupname;
+                               $grouppageLocalized = MediaWikiServices::getInstance()->getNamespaceInfo()->
+                                       getCanonicalName( NS_PROJECT ) . ':' . $groupname;
                        } else {
                                $grouppageLocalized = $msg->text();
                        }
index 30b33cc..9efa803 100644 (file)
@@ -21,6 +21,8 @@
  * @ingroup SpecialPage
  */
 
+use MediaWiki\MediaWikiServices;
+
 /**
  * A special page looking for page without any category.
  *
@@ -60,7 +62,8 @@ class UncategorizedPagesPage extends PageQueryPage {
                                'cl_from IS NULL',
                                'page_namespace' => $this->requestedNamespace !== false
                                                ? $this->requestedNamespace
-                                               : MWNamespace::getContentNamespaces(),
+                                               : MediaWikiServices::getInstance()->getNamespaceInfo()->
+                                                       getContentNamespaces(),
                                'page_is_redirect' => 0
                        ],
                        'join_conds' => [
@@ -72,7 +75,10 @@ class UncategorizedPagesPage extends PageQueryPage {
        function getOrderFields() {
                // For some crazy reason ordering by a constant
                // causes a filesort
-               if ( $this->requestedNamespace === false && count( MWNamespace::getContentNamespaces() ) > 1 ) {
+               if ( $this->requestedNamespace === false &&
+                       count( MediaWikiServices::getInstance()->getNamespaceInfo()->
+                               getContentNamespaces() ) > 1
+               ) {
                        return [ 'page_namespace', 'page_title' ];
                }
 
index a1e5156..548e921 100644 (file)
@@ -22,6 +22,8 @@
  * @author Rob Church <robchur@gmail.com>
  */
 
+use MediaWiki\MediaWikiServices;
+
 /**
  * Special page lists pages without language links
  *
@@ -91,7 +93,8 @@ class WithoutInterwikiPage extends PageQueryPage {
                        ],
                        'conds' => [
                                'll_title IS NULL',
-                               'page_namespace' => MWNamespace::getContentNamespaces(),
+                               'page_namespace' => MediaWikiServices::getInstance()->getNamespaceInfo()->
+                                       getContentNamespaces(),
                                'page_is_redirect' => 0
                        ],
                        'join_conds' => [ 'langlinks' => [ 'LEFT JOIN', 'll_from = page_id' ] ]
index 7a47edf..be28417 100644 (file)
@@ -415,7 +415,8 @@ class UploadForm extends HTMLForm {
                        'wgCheckFileExtensions' => $config->get( 'CheckFileExtensions' ),
                        'wgStrictFileExtensions' => $config->get( 'StrictFileExtensions' ),
                        'wgFileExtensions' => array_values( array_unique( $config->get( 'FileExtensions' ) ) ),
-                       'wgCapitalizeUploads' => MWNamespace::isCapitalized( NS_FILE ),
+                       'wgCapitalizeUploads' => MediaWikiServices::getInstance()->getNamespaceInfo()->
+                               isCapitalized( NS_FILE ),
                        'wgMaxUploadSize' => $this->mMaxUploadSize,
                        'wgFileCanRotate' => SpecialUpload::rotationEnabled(),
                ];
index a187a44..e0db715 100644 (file)
@@ -386,7 +386,7 @@ class ContribsPager extends RangeChronologicalPager {
                        }
 
                        $associatedNS = $this->mDb->addQuotes(
-                               MWNamespace::getAssociated( $this->namespace )
+                               MediaWikiServices::getInstance()->getAssociated( $this->namespace )
                        );
 
                        return [
index 4da9395..1a6ba72 100644 (file)
@@ -46,7 +46,10 @@ class NaiveImportTitleFactory implements ImportTitleFactory {
 
                        // For built-in namespaces (0 <= ID < 100), we try to find a local NS with
                        // the same namespace ID
-                       if ( $foreignNs < 100 && MWNamespace::exists( $foreignNs ) ) {
+                       if (
+                               $foreignNs < 100 &&
+                               MediaWikiServices::getInstance()->getNamespaceInfo()->exists( $foreignNs )
+                       ) {
                                return Title::makeTitleSafe( $foreignNs, $foreignTitle->getText() );
                        }
                }
index 7c756aa..7a44d0a 100644 (file)
@@ -18,6 +18,8 @@
  * @file
  */
 
+use MediaWiki\MediaWikiServices;
+
 /**
  * A class to convert page titles on a foreign wiki (ForeignTitle objects) into
  * page titles on the local wiki (Title objects), placing all pages in a fixed
@@ -31,7 +33,7 @@ class NamespaceImportTitleFactory implements ImportTitleFactory {
         * @param int $ns The namespace to use for all pages
         */
        public function __construct( $ns ) {
-               if ( !MWNamespace::exists( $ns ) ) {
+               if ( !MediaWikiServices::getInstance()->getNamespaceInfo()->exists( $ns ) ) {
                        throw new MWException( "Namespace $ns doesn't exist on this wiki" );
                }
                $this->ns = $ns;
index 4244350..415196a 100644 (file)
@@ -18,6 +18,8 @@
  * @file
  */
 
+use MediaWiki\MediaWikiServices;
+
 /**
  * A class to convert page titles on a foreign wiki (ForeignTitle objects) into
  * page titles on the local wiki (Title objects), placing all pages as subpages
@@ -32,7 +34,10 @@ class SubpageImportTitleFactory implements ImportTitleFactory {
         * created
         */
        public function __construct( Title $rootPage ) {
-               if ( !MWNamespace::hasSubpages( $rootPage->getNamespace() ) ) {
+               if (
+                       !MediaWikiServices::getInstance()->getNamespaceInfo()->
+                               hasSubpages( $rootPage->getNamespace() )
+               ) {
                        throw new MWException( "The root page you specified, $rootPage, is in a " .
                                "namespace where subpages are not allowed" );
                }
index 66674dc..41facc7 100644 (file)
@@ -64,9 +64,11 @@ class ExternalUserNames {
                if ( $pos !== false ) {
                        $iw = explode( ':', substr( $userName, 0, $pos ) );
                        $firstIw = array_shift( $iw );
-                       $interwikiLookup = MediaWikiServices::getInstance()->getInterwikiLookup();
+                       $services = MediaWikiServices::getInstance();
+                       $interwikiLookup = $services->getInterwikiLookup();
                        if ( $interwikiLookup->isValidInterwiki( $firstIw ) ) {
-                               $title = MWNamespace::getCanonicalName( NS_USER ) . ':' . substr( $userName, $pos + 1 );
+                               $title = $services->getNamespaceInfo()->getCanonicalName( NS_USER ) .
+                                       ':' . substr( $userName, $pos + 1 );
                                if ( $iw ) {
                                        $title = implode( ':', $iw ) . ':' . $title;
                                }
index 5106c17..66b6566 100644 (file)
@@ -6,7 +6,6 @@ use Hooks;
 use Html;
 use MediaWiki\MediaWikiServices;
 use MediaWiki\Widget\SearchInputWidget;
-use MWNamespace;
 use SearchEngineConfig;
 use SpecialSearch;
 use Xml;
@@ -240,7 +239,8 @@ class SearchFormWidget {
                $activeNamespaces = $this->specialSearch->getNamespaces();
                $langConverter = $this->specialSearch->getLanguage();
                foreach ( $this->searchConfig->searchableNamespaces() as $namespace => $name ) {
-                       $subject = MWNamespace::getSubject( $namespace );
+                       $subject = MediaWikiServices::getInstance()->getNamespaceInfo()->
+                               getSubject( $namespace );
                        if ( !isset( $rows[$subject] ) ) {
                                $rows[$subject] = "";
                        }
index 539bdf4..7b89a9c 100644 (file)
@@ -27,6 +27,7 @@
  */
 
 use CLDRPluralRuleParser\Evaluator;
+use MediaWiki\MediaWikiServices;
 use Wikimedia\Assert\Assert;
 
 /**
@@ -506,7 +507,8 @@ class Language {
                if ( is_null( $this->namespaceNames ) ) {
                        global $wgMetaNamespace, $wgMetaNamespaceTalk, $wgExtraNamespaces;
 
-                       $validNamespaces = MWNamespace::getCanonicalNamespaces();
+                       $validNamespaces = MediaWikiServices::getInstance()->getNamespaceInfo()->
+                               getCanonicalNamespaces();
 
                        $this->namespaceNames = $wgExtraNamespaces +
                                self::$dataCache->getItem( $this->mCode, 'namespaceNames' );
@@ -744,7 +746,8 @@ class Language {
         */
        public function getNsIndex( $text ) {
                $lctext = $this->lc( $text );
-               $ns = MWNamespace::getCanonicalIndex( $lctext );
+               $ns = MediaWikiServices::getInstance()->getNamespaceInfo()->
+                       getCanonicalIndex( $lctext );
                if ( $ns !== null ) {
                        return $ns;
                }
index 1b49f0e..20be9fd 100644 (file)
@@ -55,7 +55,10 @@ class CleanupCaps extends TableCleanup {
 
                $this->namespace = intval( $this->getOption( 'namespace', 0 ) );
 
-               if ( MWNamespace::isCapitalized( $this->namespace ) ) {
+               if (
+                       MediaWikiServices::getInstance()->getNamespaceInfo()->
+                               isCapitalized( $this->namespace )
+               ) {
                        $this->output( "Will be moving pages to first letter capitalized titles" );
                        $callback = 'processRowToUppercase';
                } else {
index 7f0e340..cad6122 100644 (file)
@@ -152,7 +152,7 @@ class TitleCleanup extends TableCleanup {
 
                        # Namespace which no longer exists. Put the page in the main namespace
                        # since we don't have any idea of the old namespace name. See T70501.
-                       if ( !MWNamespace::exists( $ns ) ) {
+                       if ( !MediaWikiServices::getInstance()->getNamespaceInfo()->exists( $ns ) ) {
                                $ns = 0;
                        }
 
index af5373c..7d43f21 100644 (file)
@@ -290,7 +290,7 @@ class GenerateSitemap extends Maintenance {
         * @return string
         */
        function guessPriority( $namespace ) {
-               return MWNamespace::isSubject( $namespace )
+               return MediaWikiServices::getInstance()->getNamespaceInfo()->isSubject( $namespace )
                        ? $this->priorities[self::GS_MAIN]
                        : $this->priorities[self::GS_TALK];
        }
index 075d6f2..3c73306 100644 (file)
@@ -117,7 +117,10 @@ class NamespaceDupes extends Maintenance {
                }
 
                // Now pull in all canonical and alias namespaces...
-               foreach ( MWNamespace::getCanonicalNamespaces() as $ns => $name ) {
+               foreach (
+                       MediaWikiServices::getInstance()->getNamespaceInfo()->getCanonicalNamespaces()
+                       as $ns => $name
+               ) {
                        // This includes $wgExtraNamespaces
                        if ( $name !== '' ) {
                                $spaces[$name] = $ns;
@@ -429,7 +432,10 @@ class NamespaceDupes extends Maintenance {
         * @return ResultWrapper
         */
        private function getTargetList( $ns, $name, $options ) {
-               if ( $options['move-talk'] && MWNamespace::isSubject( $ns ) ) {
+               if (
+                       $options['move-talk'] &&
+                       MediaWikiServices::getInstance()->getNamespaceInfo()->isSubject( $ns )
+               ) {
                        $checkNamespaces = [ NS_MAIN, NS_TALK ];
                } else {
                        $checkNamespaces = NS_MAIN;
@@ -465,9 +471,10 @@ class NamespaceDupes extends Maintenance {
                        $dbk = "$name-" . $dbk;
                }
                $destNS = $ns;
-               if ( $sourceNs == NS_TALK && MWNamespace::isSubject( $ns ) ) {
+               $nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
+               if ( $sourceNs == NS_TALK && $nsInfo->isSubject( $ns ) ) {
                        // This is an associated talk page moved with the --move-talk feature.
-                       $destNS = MWNamespace::getTalk( $destNS );
+                       $destNS = $nsInfo->getTalk( $destNS );
                }
                $newTitle = Title::makeTitleSafe( $destNS, $dbk );
                if ( !$newTitle || !$newTitle->canExist() ) {
index cf398ff..2cdf418 100644 (file)
@@ -21,6 +21,8 @@
  * @ingroup Maintenance
  */
 
+use MediaWiki\MediaWikiServices;
+
 require_once __DIR__ . '/Maintenance.php';
 
 /**
@@ -102,7 +104,8 @@ class RebuildFileCache extends Maintenance {
                        // Get the pages
                        $res = $dbr->select( 'page',
                                [ 'page_namespace', 'page_title', 'page_id' ],
-                               [ 'page_namespace' => MWNamespace::getContentNamespaces(),
+                               [ 'page_namespace' => MediaWikiServices::getInstance()->getNamespaceInfo()->
+                                       getContentNamespaces(),
                                        "page_id BETWEEN " . (int)$blockStart . " AND " . (int)$blockEnd ],
                                __METHOD__,
                                [ 'ORDER BY' => 'page_id ASC', 'USE INDEX' => 'PRIMARY' ]
index df897d9..3b63c19 100644 (file)
@@ -1080,7 +1080,8 @@ class ParserTestRunner {
                        'wgLanguageCode' => $langCode,
                        'wgRawHtml' => self::getOptionValue( 'wgRawHtml', $opts, false ),
                        'wgNamespacesWithSubpages' => array_fill_keys(
-                               MWNamespace::getValidNamespaces(), isset( $opts['subpage'] )
+                               MediaWikiServices::getInstance()->getNamespaceInfo()->getValidNamespaces(),
+                               isset( $opts['subpage'] )
                        ),
                        'wgMaxTocLevel' => $maxtoclevel,
                        'wgAllowExternalImages' => self::getOptionValue( 'wgAllowExternalImages', $opts, true ),
index ec61c23..1e70c57 100644 (file)
@@ -2244,18 +2244,19 @@ abstract class MediaWikiTestCase extends PHPUnit\Framework\TestCase {
                }
 
                // NOTE: prefer content namespaces
+               $nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
                $namespaces = array_unique( array_merge(
-                       MWNamespace::getContentNamespaces(),
+                       $nsInfo->getContentNamespaces(),
                        [ NS_MAIN, NS_HELP, NS_PROJECT ], // prefer these
-                       MWNamespace::getValidNamespaces()
+                       $nsInfo->getValidNamespaces()
                ) );
 
                $namespaces = array_diff( $namespaces, [
                        NS_FILE, NS_CATEGORY, NS_MEDIAWIKI, NS_USER // don't mess with magic namespaces
                ] );
 
-               $talk = array_filter( $namespaces, function ( $ns ) {
-                       return MWNamespace::isTalk( $ns );
+               $talk = array_filter( $namespaces, function ( $ns ) use ( $nsInfo ) {
+                       return $nsInfo->isTalk( $ns );
                } );
 
                // prefer non-talk pages
index 646b487..222b3e3 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use MediaWiki\MediaWikiServices;
+
 /**
  * @covers PageProps
  *
@@ -234,7 +236,8 @@ class PagePropsTest extends MediaWikiLangTestCase {
                                ( $model === null || $model === CONTENT_MODEL_WIKITEXT )
                        ) {
                                $ns = $this->getDefaultWikitextNS();
-                               $page = MWNamespace::getCanonicalName( $ns ) . ':' . $page;
+                               $page = MediaWikiServices::getInstance()->getNamespaceInfo()->
+                                       getCanonicalName( $ns ) . ':' . $page;
                        }
 
                        $page = Title::newFromText( $page );
index 96e2766..7501167 100644 (file)
@@ -182,7 +182,8 @@ abstract class RevisionDbTestBase extends MediaWikiTestCase {
                        ( $model === null || $model === CONTENT_MODEL_WIKITEXT )
                ) {
                        $ns = $this->getDefaultWikitextNS();
-                       $titleString = MWNamespace::getCanonicalName( $ns ) . ':' . $titleString;
+                       $titleString = MediaWikiServices::getInstance()->getNamespaceInfo()->
+                               getCanonicalName( $ns ) . ':' . $titleString;
                }
 
                $title = Title::newFromText( $titleString );
index e02e8a4..4e19822 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 
+use MediaWiki\MediaWikiServices;
 use Wikimedia\TestingAccessWrapper;
 
 /**
@@ -643,7 +644,7 @@ class ApiBaseTest extends ApiTestCase {
                                        ApiBase::PARAM_ISMULTI => true,
                                        ApiBase::PARAM_TYPE => 'namespace',
                                ],
-                               MWNamespace::getValidNamespaces(),
+                               MediaWikiServices::getInstance()->getNamespaceInfo()->getValidNamespaces(),
                                [],
                        ],
                        // PARAM_ALL is ignored with namespace types.
@@ -654,7 +655,7 @@ class ApiBaseTest extends ApiTestCase {
                                        ApiBase::PARAM_TYPE => 'namespace',
                                        ApiBase::PARAM_ALL => false,
                                ],
-                               MWNamespace::getValidNamespaces(),
+                               MediaWikiServices::getInstance()->getNamespaceInfo()->getValidNamespaces(),
                                [],
                        ],
                        'Namespace with wildcard "x"' => [
index 4195f96..a63521a 100644 (file)
@@ -177,7 +177,7 @@ class TextboxBuilderTest extends MediaWikiTestCase {
                $expected
        ) {
                $this->setMwGlobals( [
-                       // set to trick MWNamespace::getRestrictionLevels
+                       // set to trick NamespaceInfo::getRestrictionLevels
                        'wgRestrictionLevels' => $restrictionLevels
                ] );
 
index 2453353..0d10a20 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 
+use MediaWiki\MediaWikiServices;
 use Wikimedia\TestingAccessWrapper;
 
 /**
@@ -566,7 +567,8 @@ class ApiStructureTest extends MediaWikiTestCase {
                                break;
 
                        case 'namespace':
-                               $validValues = MWNamespace::getValidNamespaces();
+                               $validValues = MediaWikiServices::getInstance()->getNamespaceInfo()->
+                                       getValidNamespaces();
                                if (
                                        isset( $config[ApiBase::PARAM_EXTRA_NAMESPACES] ) &&
                                        is_array( $config[ApiBase::PARAM_EXTRA_NAMESPACES] )