Merge "Some love to UserDupes"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Fri, 21 Jun 2019 01:26:15 +0000 (01:26 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 21 Jun 2019 01:26:15 +0000 (01:26 +0000)
16 files changed:
RELEASE-NOTES-1.34
includes/DefaultSettings.php
includes/GlobalFunctions.php
includes/OutputPage.php
includes/block/BlockManager.php
includes/block/DatabaseBlock.php
includes/config/ServiceOptions.php
includes/installer/WebInstallerOutput.php
includes/parser/Parser.php
includes/parser/ParserOptions.php
languages/i18n/en.json
resources/src/startup/startup.js
tests/phpunit/includes/block/BlockManagerTest.php
tests/phpunit/structure/ResourcesTest.php
tests/qunit/data/load.mock.php
tests/qunit/data/styleTest.css.php

index 431db3d..67aa371 100644 (file)
@@ -153,9 +153,10 @@ because of Phabricator reports.
 * User::makeGroupLinkWiki(), deprecated in 1.29, has been removed. Use
   UserGroupMembership::getLink() instead.
 * SavepointPostgres, deprecated in 1.31, has been removed.
-* Output::sectionEditLinksEnabled(), ParserOutput::getEditSectionTokens,
-  ::getTOCEnabled, ::setEditSectionTokens, ::setTOCEnabled, deprecated in 1.31,
-  have been removed.
+* OutputPage::enableSectionEditLinks(), OutputPage::sectionEditLinksEnabled(),
+  ParserOptions::getEditSection(), ParserOptions::setEditSection(), and
+  ParserOutput::getEditSectionTokens, ::getTOCEnabled, ::setEditSectionTokens,
+  and ::setTOCEnabled, deprecated in 1.31, have been removed.
 * EditPage::safeUnicodeInput() and ::safeUnicodeOutput(), deprecated in 1.30,
   have been removed.
 * Four methods in OutputPage, deprecated in 1.32, have been removed. You should
@@ -217,6 +218,12 @@ because of Phabricator reports.
   removed.
 * The $wgUseKeyHeader configuration option and the OutputPage::getKeyHeader()
   method, deprecated in 1.32, have been removed.
+* WebInstallerOutput::addWikiText(), deprecated in 1.32, has been removed.
+* Parser::fetchFile(), deprecated in 1.32, has been removed. Use the method
+  Parser::fetchFileAndTitle() instead.
+* The global function wfBCP47, deprecated in 1.31, has been removed.
+* wfCountDown() function, deprecated in 1.31, has been removed. Use
+  \Maintenance::countDown() method instead.
 * …
 
 === Deprecations in 1.34 ===
index c5a2f77..2075432 100644 (file)
@@ -4142,8 +4142,7 @@ $wgInvalidRedirectTargets = [ 'Filepath', 'Mypage', 'Mytalk', 'Redirect' ];
  *                    temporary storage. Preprocessor_DOM generally uses less memory;
  *                    the speed of the two is roughly the same.
  *
- *                    If this parameter is not given, it uses Preprocessor_DOM if the
- *                    DOM module is available, otherwise it uses Preprocessor_Hash.
+ *                    If this parameter is not given, it uses Preprocessor_Hash.
  *
  * The Preprocessor_DOM class is deprecated, and will be removed in a future
  * release.
index 759732f..c3829be 100644 (file)
@@ -2762,30 +2762,6 @@ function wfWaitForSlaves(
        return $lbFactory->waitForReplication( $opts );
 }
 
-/**
- * Count down from $seconds to zero on the terminal, with a one-second pause
- * between showing each number. For use in command-line scripts.
- *
- * @deprecated since 1.31, use Maintenance::countDown()
- *
- * @codeCoverageIgnore
- * @param int $seconds
- */
-function wfCountDown( $seconds ) {
-       wfDeprecated( __FUNCTION__, '1.31' );
-       for ( $i = $seconds; $i >= 0; $i-- ) {
-               if ( $i != $seconds ) {
-                       echo str_repeat( "\x08", strlen( $i + 1 ) );
-               }
-               echo $i;
-               flush();
-               if ( $i ) {
-                       sleep( 1 );
-               }
-       }
-       echo "\n";
-}
-
 /**
  * Replace all invalid characters with '-'.
  * Additional characters can be defined in $wgIllegalFileChars (see T22489).
@@ -2885,21 +2861,6 @@ function wfShorthandToInteger( $string = '', $default = -1 ) {
        return $val;
 }
 
-/**
- * Get the normalised IETF language tag
- * See unit test for examples.
- * See mediawiki.language.bcp47 for the JavaScript implementation.
- *
- * @deprecated since 1.31, use LanguageCode::bcp47() directly.
- *
- * @param string $code The language code.
- * @return string The language code which complying with BCP 47 standards.
- */
-function wfBCP47( $code ) {
-       wfDeprecated( __METHOD__, '1.31' );
-       return LanguageCode::bcp47( $code );
-}
-
 /**
  * Get a specific cache object.
  *
index fba75ec..6c49696 100644 (file)
@@ -4017,16 +4017,6 @@ class OutputPage extends ContextSource {
                return $this->mEnableTOC;
        }
 
-       /**
-        * Enables/disables section edit links, doesn't override __NOEDITSECTION__
-        * @param bool $flag
-        * @since 1.23
-        * @deprecated since 1.31, use $poOptions to addParserOutput() instead.
-        */
-       public function enableSectionEditLinks( $flag = true ) {
-               wfDeprecated( __METHOD__, '1.31' );
-       }
-
        /**
         * Helper function to setup the PHP implementation of OOUI to use in this request.
         *
index 41ff893..abd2db2 100644 (file)
@@ -223,25 +223,32 @@ class BlockManager {
        }
 
        /**
-        * Given a list of blocks, return a list blocks where each block either has a
-        * unique ID or has ID null.
+        * Given a list of blocks, return a list of unique blocks.
+        *
+        * This usually means that each block has a unique ID. For a block with ID null,
+        * if it's an autoblock, it will be filtered out if the parent block is present;
+        * if not, it is assumed to be a unique system block, and kept.
         *
         * @param AbstractBlock[] $blocks
         * @return AbstractBlock[]
         */
        private function getUniqueBlocks( $blocks ) {
-               $blockIds = [];
-               $uniqueBlocks = [];
+               $systemBlocks = [];
+               $databaseBlocks = [];
+
                foreach ( $blocks as $block ) {
-                       $id = $block->getId();
-                       if ( $id === null ) {
-                               $uniqueBlocks[] = $block;
-                       } elseif ( !isset( $blockIds[$id] ) ) {
-                               $uniqueBlocks[] = $block;
-                               $blockIds[$block->getId()] = true;
+                       if ( $block instanceof SystemBlock ) {
+                               $systemBlocks[] = $block;
+                       } elseif ( $block->getType() === DatabaseBlock::TYPE_AUTO ) {
+                               if ( !isset( $databaseBlocks[$block->getParentBlockId()] ) ) {
+                                       $databaseBlocks[$block->getParentBlockId()] = $block;
+                               }
+                       } else {
+                               $databaseBlocks[$block->getId()] = $block;
                        }
                }
-               return $uniqueBlocks;
+
+               return array_merge( $systemBlocks, $databaseBlocks );
        }
 
        /**
index ba08d54..0f19324 100644 (file)
@@ -1045,6 +1045,14 @@ class DatabaseBlock extends AbstractBlock {
                return $this;
        }
 
+       /**
+        * @since 1.34
+        * @return int|null If this is an autoblock, ID of the parent block; otherwise null
+        */
+       public function getParentBlockId() {
+               return $this->mParentBlockId;
+       }
+
        /**
         * Get/set a flag determining whether the master is used for reads
         *
index 0f3743f..6ae059e 100644 (file)
@@ -23,6 +23,7 @@ use Wikimedia\Assert\Assert;
  * @since 1.34
  */
 class ServiceOptions {
+       private $keys = [];
        private $options = [];
 
        /**
@@ -33,6 +34,7 @@ class ServiceOptions {
         * @throws InvalidArgumentException if one of $keys is not found in any of $sources
         */
        public function __construct( array $keys, ...$sources ) {
+               $this->keys = $keys;
                foreach ( $keys as $key ) {
                        foreach ( $sources as $source ) {
                                if ( $source instanceof Config ) {
@@ -58,20 +60,21 @@ class ServiceOptions {
         * @param string[] $expectedKeys
         */
        public function assertRequiredOptions( array $expectedKeys ) {
-               $actualKeys = array_keys( $this->options );
-               $extraKeys = array_diff( $actualKeys, $expectedKeys );
-               $missingKeys = array_diff( $expectedKeys, $actualKeys );
-               Assert::precondition( !$extraKeys && !$missingKeys,
-                       (
-                       $extraKeys
-                               ? 'Unsupported options passed: ' . implode( ', ', $extraKeys ) . '!'
-                               : ''
-                       ) . ( $extraKeys && $missingKeys ? ' ' : '' ) . (
-                       $missingKeys
-                               ? 'Required options missing: ' . implode( ', ', $missingKeys ) . '!'
-                               : ''
-                       )
-               );
+               if ( $this->keys !== $expectedKeys ) {
+                       $extraKeys = array_diff( $this->keys, $expectedKeys );
+                       $missingKeys = array_diff( $expectedKeys, $this->keys );
+                       Assert::precondition( !$extraKeys && !$missingKeys,
+                               (
+                               $extraKeys
+                                       ? 'Unsupported options passed: ' . implode( ', ', $extraKeys ) . '!'
+                                       : ''
+                               ) . ( $extraKeys && $missingKeys ? ' ' : '' ) . (
+                               $missingKeys
+                                       ? 'Required options missing: ' . implode( ', ', $missingKeys ) . '!'
+                                       : ''
+                               )
+                       );
+               }
        }
 
        /**
index 65e7457..cbb9b57 100644 (file)
@@ -90,15 +90,6 @@ class WebInstallerOutput {
                $this->flush();
        }
 
-       /**
-        * @param string $text
-        * @deprecated since 1.32; use addWikiTextAsInterface instead
-        */
-       public function addWikiText( $text ) {
-               wfDeprecated( __METHOD__, '1.32' );
-               $this->addWikiTextAsInterface( $text );
-       }
-
        /**
         * @param string $text
         * @since 1.32
index c61de38..59f2db4 100644 (file)
@@ -3836,19 +3836,6 @@ class Parser {
                        'deps' => $deps ];
        }
 
-       /**
-        * Fetch a file and its title and register a reference to it.
-        * If 'broken' is a key in $options then the file will appear as a broken thumbnail.
-        * @param Title $title
-        * @param array $options Array of options to RepoGroup::findFile
-        * @return File|bool
-        * @deprecated since 1.32, use fetchFileAndTitle instead
-        */
-       public function fetchFile( $title, $options = [] ) {
-               wfDeprecated( __METHOD__, '1.32' );
-               return $this->fetchFileAndTitle( $title, $options )[0];
-       }
-
        /**
         * Fetch a file and its title and register a reference to it.
         * If 'broken' is a key in $options then the file will appear as a broken thumbnail.
index 66b1612..afd6b2d 100644 (file)
@@ -913,27 +913,6 @@ class ParserOptions {
                return wfSetVar( $this->mTimestamp, $x );
        }
 
-       /**
-        * Create "edit section" links?
-        * @deprecated since 1.31, use ParserOutput::getText() options instead.
-        * @return bool
-        */
-       public function getEditSection() {
-               wfDeprecated( __METHOD__, '1.31' );
-               return true;
-       }
-
-       /**
-        * Create "edit section" links?
-        * @deprecated since 1.31, use ParserOutput::getText() options instead.
-        * @param bool|null $x New value (null is no change)
-        * @return bool Old value
-        */
-       public function setEditSection( $x ) {
-               wfDeprecated( __METHOD__, '1.31' );
-               return true;
-       }
-
        /**
         * Set the redirect target.
         *
index 4c32ec6..425cf2b 100644 (file)
        "history": "Page history",
        "history_short": "History",
        "history_small": "history",
-       "updatedmarker": "updated since my last visit",
+       "updatedmarker": "updated since your last visit",
        "printableversion": "Printable version",
        "permalink": "Permanent link",
        "print": "Print",
index c251a86..da048ff 100644 (file)
@@ -74,7 +74,7 @@ function isCompatible( ua ) {
                //
                // Please extend the regex instead of adding new ones!
                // And add a test case to startup.test.js
-               !ua.match( /MSIE 10|webOS\/1\.[0-4]|SymbianOS|Series60|NetFront|Opera Mini|S40OviBrowser|MeeGo|Android.+Glass|^Mozilla\/5\.0 .+ Gecko\/$|googleweblight|PLAYSTATION|PlayStation/ )
+               !ua.match( /MSIE 10|webOS\/1\.[0-4]|SymbianOS|NetFront|Opera Mini|S40OviBrowser|MeeGo|Android.+Glass|^Mozilla\/5\.0 .+ Gecko\/$|googleweblight|PLAYSTATION|PlayStation/ )
        );
 }
 
index 39a5534..40fe4c8 100644 (file)
@@ -2,6 +2,7 @@
 
 use MediaWiki\Block\BlockManager;
 use MediaWiki\Block\DatabaseBlock;
+use MediaWiki\Block\SystemBlock;
 
 /**
  * @group Blocking
@@ -288,4 +289,38 @@ class BlockManagerTest extends MediaWikiTestCase {
                        ],
                ];
        }
+
+       /**
+        * @covers ::getUniqueBlocks
+        */
+       public function testGetUniqueBlocks() {
+               $blockId = 100;
+
+               $class = new ReflectionClass( BlockManager::class );
+               $method = $class->getMethod( 'getUniqueBlocks' );
+               $method->setAccessible( true );
+
+               $blockManager = $this->getBlockManager( [] );
+
+               $block = $this->getMockBuilder( DatabaseBlock::class )
+                       ->setMethods( [ 'getId' ] )
+                       ->getMock();
+               $block->expects( $this->any() )
+                       ->method( 'getId' )
+                       ->willReturn( $blockId );
+
+               $autoblock = $this->getMockBuilder( DatabaseBlock::class )
+                       ->setMethods( [ 'getParentBlockId', 'getType' ] )
+                       ->getMock();
+               $autoblock->expects( $this->any() )
+                       ->method( 'getParentBlockId' )
+                       ->willReturn( $blockId );
+               $autoblock->expects( $this->any() )
+                       ->method( 'getType' )
+                       ->willReturn( DatabaseBlock::TYPE_AUTO );
+
+               $blocks = [ $block, $block, $autoblock, new SystemBlock() ];
+
+               $this->assertSame( 2, count( $method->invoke( $blockManager, $blocks ) ) );
+       }
 }
index 4c34208..78e5763 100644 (file)
@@ -9,11 +9,9 @@ use Wikimedia\TestingAccessWrapper;
  * @author Antoine Musso
  * @author Niklas Laxström
  * @author Santhosh Thottingal
- * @author Timo Tijhof
  * @copyright © 2012, Antoine Musso
  * @copyright © 2012, Niklas Laxström
  * @copyright © 2012, Santhosh Thottingal
- * @copyright © 2012, Timo Tijhof
  */
 class ResourcesTest extends MediaWikiTestCase {
 
index 9f57190..1525f04 100644 (file)
@@ -18,9 +18,7 @@
  * http://www.gnu.org/copyleft/gpl.html
  *
  * @file
- * @package MediaWiki
  * @author Lupo
- * @since 1.20
  */
 
 // This file doesn't run as part of MediaWiki
index db96fd5..5d229a3 100644 (file)
@@ -18,9 +18,6 @@
  * http://www.gnu.org/copyleft/gpl.html
  *
  * @file
- * @package MediaWiki
- * @author Timo Tijhof
- * @since 1.20
  */
 
 // This file doesn't run as part of MediaWiki