Merge "Move Title::isNamespaceProtected() to PermissionManager."
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 28 Aug 2019 09:19:14 +0000 (09:19 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 28 Aug 2019 09:19:14 +0000 (09:19 +0000)
1  2 
includes/Title.php
tests/phpunit/includes/TitlePermissionTest.php

diff --combined includes/Title.php
@@@ -2499,6 -2499,7 +2499,7 @@@ class Title implements LinkTarget, IDBA
         * Determines if $user is unable to edit this page because it has been protected
         * by $wgNamespaceProtection.
         *
+        * @deprecated since 1.34 Don't use this function in new code.
         * @param User $user User object to check permissions
         * @return bool
         */
        public static function capitalize( $text, $ns = NS_MAIN ) {
                $services = MediaWikiServices::getInstance();
                if ( $services->getNamespaceInfo()->isCapitalized( $ns ) ) {
 -                      return MediaWikiServices::getInstance()->getContentLanguage()->ucfirst( $text );
 +                      return $services->getContentLanguage()->ucfirst( $text );
                } else {
                        return $text;
                }
@@@ -410,7 -410,6 +410,6 @@@ class TitlePermissionTest extends Media
         * @covers \MediaWiki\Permissions\PermissionManager::checkSpecialsAndNSPermissions
         */
        public function testSpecialsAndNSPermissions() {
-               global $wgNamespaceProtection;
                $this->setUser( $this->userName );
  
                $this->setTitle( NS_SPECIAL );
                $this->assertEquals( [ [ 'badaccess-group0' ] ],
                        $this->title->getUserPermissionsErrors( 'bogus', $this->user ) );
  
-               $wgNamespaceProtection[NS_USER] = [ 'bogus' ];
+               $this->mergeMwGlobalArrayValue( 'wgNamespaceProtection', [
+                       NS_USER => [ 'bogus' ]
+               ] );
+               $this->resetServices();
                $this->setTitle( NS_USER );
                $this->overrideUserPermissions( $this->user );
                $this->assertEquals( [ [ 'badaccess-group0' ],
                $this->assertEquals( [ [ 'protectedinterface', 'bogus' ] ],
                        $this->title->getUserPermissionsErrors( 'bogus', $this->user ) );
  
-               $wgNamespaceProtection = null;
+               $this->setMwGlobals( 'wgNamespaceProtection', null );
+               $this->resetServices();
                $this->overrideUserPermissions( $this->user, 'bogus' );
                $this->assertEquals( [],
                        $this->title->getUserPermissionsErrors( 'bogus', $this->user ) );
                        'address' => '127.0.8.1',
                        'by' => $this->user->getId(),
                        'reason' => 'no reason given',
 -                      'timestamp' => $prev + 3600,
 +                      'timestamp' => $prev,
                        'auto' => true,
                        'expiry' => 0
                ] );
 -              $this->user->mBlock->setTimestamp( 0 );
                $this->assertEquals( [ [ 'autoblockedtext',
                                "[[User:Useruser|\u{202A}Useruser\u{202C}]]", 'no reason given', '127.0.0.1',
                                "\u{202A}Useruser\u{202C}", null, 'infinite', '127.0.8.1',