Merge "Localisation updates from https://translatewiki.net."
authorD3r1ck01 <xsavitar.wiki@aol.com>
Wed, 28 Aug 2019 09:46:06 +0000 (09:46 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 28 Aug 2019 09:46:06 +0000 (09:46 +0000)
13 files changed:
RELEASE-NOTES-1.34
includes/DefaultSettings.php
includes/Permissions/PermissionManager.php
includes/Title.php
includes/filebackend/lockmanager/LockManagerGroup.php
includes/filebackend/lockmanager/LockManagerGroupFactory.php
includes/libs/mime/XmlTypeCheck.php
includes/profiler/Profiler.php
includes/rcfeed/IRCColourfulRCFeedFormatter.php
maintenance/tables.sql
tests/phpunit/includes/Permissions/PermissionManagerTest.php
tests/phpunit/includes/TitlePermissionTest.php
tests/phpunit/includes/filebackend/lockmanager/LockManagerGroupIntegrationTest.php

index 5da679f..932122d 100644 (file)
@@ -415,6 +415,9 @@ because of Phabricator reports.
 * ResourceLoaderContext::getConfig and ResourceLoaderContext::getLogger have
   been deprecated. Inside ResourceLoaderModule subclasses, use the local methods
   instead. Elsewhere, use the methods from the ResourceLoader class.
+* The Profiler::setTemplated and Profiler::getTemplated methods have been
+  deprecated. Use Profiler::setAllowOutput and Profiler::getAllowOutput
+  instead.
 * The Preprocessor_DOM implementation has been deprecated.  It will be
   removed in a future release.  Use the Preprocessor_Hash implementation
   instead.
index 35e8ae5..93a5919 100644 (file)
@@ -788,10 +788,6 @@ $wgFileBackends = [];
  * See LockManager::__construct() for more details.
  * Additional parameters are specific to the lock manager class used.
  * These settings should be global to all wikis.
- *
- * When using DBLockManager, the 'dbsByBucket' map can reference 'localDBMaster' as
- * a peer database in each bucket. This will result in an extra connection to the domain
- * that the LockManager services, which must also be a valid wiki ID.
  */
 $wgLockManagers = [];
 
index ec0157b..43d57a7 100644 (file)
@@ -984,7 +984,7 @@ class PermissionManager {
         * Check permissions on special pages & namespaces
         *
         * @param string $action The action to check
-        * @param User $user User to check
+        * @param UserIdentity $user User to check
         * @param array $errors List of current errors
         * @param string $rigor One of PermissionManager::RIGOR_ constants
         *   - RIGOR_QUICK  : does cheap permission checks from replica DBs (usable for GUI creation)
@@ -998,7 +998,7 @@ class PermissionManager {
         */
        private function checkSpecialsAndNSPermissions(
                $action,
-               User $user,
+               UserIdentity $user,
                $errors,
                $rigor,
                $short,
@@ -1014,7 +1014,7 @@ class PermissionManager {
                }
 
                # Check $wgNamespaceProtection for restricted namespaces
-               if ( $title->isNamespaceProtected( $user ) ) {
+               if ( $this->isNamespaceProtected( $title->getNamespace(), $user ) ) {
                        $ns = $title->getNamespace() == NS_MAIN ?
                                wfMessage( 'nstab-main' )->text() : $title->getNsText();
                        $errors[] = $title->getNamespace() == NS_MEDIAWIKI ?
@@ -1453,6 +1453,20 @@ class PermissionManager {
                return $this->allRights;
        }
 
+       /**
+        * Determines if $user is unable to edit pages in namespace because it has been protected.
+        * @param $index
+        * @param UserIdentity $user
+        * @return bool
+        */
+       private function isNamespaceProtected( $index, UserIdentity $user ) {
+               $namespaceProtection = $this->options->get( 'NamespaceProtection' );
+               if ( isset( $namespaceProtection[$index] ) ) {
+                       return !$this->userHasAllRights( $user, ...(array)$namespaceProtection[$index] );
+               }
+               return false;
+       }
+
        /**
         * Determine which restriction levels it makes sense to use in a namespace,
         * optionally filtered by a user's rights.
index eb19076..96f196f 100644 (file)
@@ -2499,6 +2499,7 @@ class Title implements LinkTarget, IDBAccessObject {
         * 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
         */
index 7da3753..9b43164 100644 (file)
@@ -104,25 +104,10 @@ class LockManagerGroup {
                // Lazy-load the actual lock manager instance
                if ( !isset( $this->managers[$name]['instance'] ) ) {
                        $class = $this->managers[$name]['class'];
+                       '@phan-var string $class';
                        $config = $this->managers[$name]['config'];
-                       if ( $class === DBLockManager::class ) {
-                               $lb = $this->lbFactory->getMainLB( $config['domain'] );
-                               $config['dbServers']['localDBMaster'] = $lb->getLazyConnectionRef(
-                                       DB_MASTER,
-                                       [],
-                                       $config['domain'],
-                                       $lb::CONN_TRX_AUTOCOMMIT
-                               );
-                               $config['srvCache'] = ObjectCache::getLocalServerInstance( 'hash' );
-                       }
                        $config['logger'] = LoggerFactory::getInstance( 'LockManager' );
 
-                       // XXX Looks like phan is right, we are trying to instantiate an abstract class and it
-                       // throws. Did this ever work? Presumably we need to detect the right subclass? Or
-                       // should we just get rid of this? It looks like it never worked since it was first
-                       // introduced by 0cf832a3394 in 2016, so if no one's complained until now, clearly it
-                       // can't be very useful?
-                       // @phan-suppress-next-line PhanTypeInstantiateAbstract
                        $this->managers[$name]['instance'] = new $class( $config );
                }
 
index 54bbc3d..9c8d4bb 100644 (file)
@@ -35,12 +35,12 @@ class LockManagerGroupFactory {
        }
 
        /**
-        * @param string|bool $domain Domain (usually wiki ID). false for the default (normally the
-        *   current wiki's domain).
+        * @param string|null|false $domain Domain (usually wiki ID). false for the default (normally
+        *   the current wiki's domain).
         * @return LockManagerGroup
         */
        public function getLockManagerGroup( $domain = false ) : LockManagerGroup {
-               if ( $domain === false ) {
+               if ( $domain === false || $domain === null ) {
                        $domain = $this->defaultDomain;
                }
 
index 65cc54b..f25287f 100644 (file)
@@ -422,7 +422,7 @@ class XmlTypeCheck {
         *  * Only contains entity definitions (e.g. No <!ATLIST )
         *  * Entity definitions are not "system" entities
         *  * Entity definitions are not "parameter" (i.e. %) entities
-        *  * Entity definitions do not reference other entites except &amp;
+        *  * Entity definitions do not reference other entities except &amp;
         *    and quotes. Entity aliases (where the entity contains only
         *    another entity are allowed)
         *  * Entity references aren't overly long (>255 bytes).
index 554ca08..0fcc97d 100644 (file)
@@ -33,14 +33,15 @@ use Wikimedia\Rdbms\TransactionProfiler;
 abstract class Profiler {
        /** @var string|bool Profiler ID for bucketing data */
        protected $profileID = false;
-       /** @var bool Whether MediaWiki is in a SkinTemplate output context */
-       protected $templated = false;
        /** @var array All of the params passed from $wgProfiler */
        protected $params = [];
        /** @var IContextSource Current request context */
        protected $context = null;
        /** @var TransactionProfiler */
        protected $trxProfiler;
+       /** @var bool */
+       private $allowOutput = false;
+
        /** @var Profiler */
        private static $instance = null;
 
@@ -264,15 +265,20 @@ abstract class Profiler {
        }
 
        /**
-        * Get the content type sent out to the client.
-        * Used for profilers that output instead of store data.
-        * @return string
+        * Get the Content-Type for deciding how to format appended profile output.
+        *
+        * Disabled by default. Enable via setAllowOutput().
+        *
+        * @see ProfilerOutputText
         * @since 1.25
+        * @return string|null Returns null if disabled or no Content-Type found.
         */
        public function getContentType() {
-               foreach ( headers_list() as $header ) {
-                       if ( preg_match( '#^content-type: (\w+/\w+);?#i', $header, $m ) ) {
-                               return $m[1];
+               if ( $this->allowOutput ) {
+                       foreach ( headers_list() as $header ) {
+                               if ( preg_match( '#^content-type: (\w+/\w+);?#i', $header, $m ) ) {
+                                       return $m[1];
+                               }
                        }
                }
                return null;
@@ -281,19 +287,42 @@ abstract class Profiler {
        /**
         * Mark this call as templated or not
         *
+        * @deprecated since 1.34 Use setAllowOutput() instead.
         * @param bool $t
         */
        public function setTemplated( $t ) {
-               $this->templated = $t;
+               // wfDeprecated( __METHOD__, '1.34' );
+               $this->allowOutput = ( $t === true );
        }
 
        /**
         * Was this call as templated or not
         *
+        * @deprecated since 1.34 Use getAllowOutput() instead.
         * @return bool
         */
        public function getTemplated() {
-               return $this->templated;
+               // wfDeprecated( __METHOD__, '1.34' );
+               return $this->getAllowOutput();
+       }
+
+       /**
+        * Enable appending profiles to standard output.
+        *
+        * @since 1.34
+        */
+       public function setAllowOutput() {
+               $this->allowOutput = true;
+       }
+
+       /**
+        * Whether appending profiles is allowed.
+        *
+        * @since 1.34
+        * @return bool
+        */
+       public function getAllowOutput() {
+               return $this->allowOutput;
        }
 
        /**
index ff85c90..4bdaca5 100644 (file)
@@ -132,7 +132,7 @@ class IRCColourfulRCFeedFormatter implements RCFeedFormatter {
        }
 
        /**
-        * Remove newlines, carriage returns and decode html entites
+        * Remove newlines, carriage returns and decode html entities
         * @param string $text
         * @return string
         */
index 254ed38..df15abf 100644 (file)
@@ -1173,7 +1173,7 @@ CREATE TABLE /*_*/image (
   -- see https://www.iana.org/assignments/media-types/
   img_minor_mime varbinary(100) NOT NULL default "unknown",
 
-  -- Description field as entered by the uploader.
+  -- Foreign key to comment table, which contains the description field as entered by the uploader.
   -- This is displayed in image upload history and logs.
   img_description_id bigint unsigned NOT NULL,
 
index 88847e2..122f377 100644 (file)
@@ -505,7 +505,6 @@ class PermissionManagerTest extends MediaWikiLangTestCase {
         * @covers MediaWiki\Permissions\PermissionManager::checkSpecialsAndNSPermissions
         */
        public function testSpecialsAndNSPermissions() {
-               global $wgNamespaceProtection;
                $this->setUser( $this->userName );
 
                $this->setTitle( NS_SPECIAL );
@@ -526,10 +525,13 @@ class PermissionManagerTest extends MediaWikiLangTestCase {
                        MediaWikiServices::getInstance()->getPermissionManager()
                                ->getPermissionErrors( 'bogus', $this->user, $this->title ) );
 
-               $wgNamespaceProtection[NS_USER] = [ 'bogus' ];
+               $this->mergeMwGlobalArrayValue( 'wgNamespaceProtection', [
+                       NS_USER => [ 'bogus' ]
+               ] );
+               $this->resetServices();
+               $this->overrideUserPermissions( $this->user, '' );
 
                $this->setTitle( NS_USER );
-               $this->overrideUserPermissions( $this->user, '' );
                $this->assertEquals( [ [ 'badaccess-group0' ],
                        [ 'namespaceprotected', 'User', 'bogus' ] ],
                        MediaWikiServices::getInstance()->getPermissionManager()
@@ -547,9 +549,10 @@ class PermissionManagerTest extends MediaWikiLangTestCase {
                        MediaWikiServices::getInstance()->getPermissionManager()
                                ->getPermissionErrors( 'bogus', $this->user, $this->title ) );
 
-               $wgNamespaceProtection = null;
-
+               $this->setMwGlobals( 'wgNamespaceProtection', null );
+               $this->resetServices();
                $this->overrideUserPermissions( $this->user, 'bogus' );
+
                $this->assertEquals( [],
                        MediaWikiServices::getInstance()->getPermissionManager()
                                ->getPermissionErrors( 'bogus', $this->user, $this->title ) );
index 208b955..91c4a13 100644 (file)
@@ -410,7 +410,6 @@ class TitlePermissionTest extends MediaWikiLangTestCase {
         * @covers \MediaWiki\Permissions\PermissionManager::checkSpecialsAndNSPermissions
         */
        public function testSpecialsAndNSPermissions() {
-               global $wgNamespaceProtection;
                $this->setUser( $this->userName );
 
                $this->setTitle( NS_SPECIAL );
@@ -428,8 +427,10 @@ class TitlePermissionTest extends MediaWikiLangTestCase {
                $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' ],
@@ -446,8 +447,8 @@ class TitlePermissionTest extends MediaWikiLangTestCase {
                $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 ) );
index 0615e95..45ad180 100644 (file)
@@ -41,7 +41,7 @@ class LockManagerGroupIntegrationTest extends MediaWikiIntegrationTestCase {
                LockManagerGroup::destroySingletons();
 
                $this->assertSame(
-                       null,
+                       WikiMap::getCurrentWikiDbDomain()->getId(),
                        LockManagerGroup::singleton( null )->config( 'a' )['domain']
                );
        }