Merge "resources: Make manageForeignResources a regular maint script"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Mon, 25 Mar 2019 20:04:08 +0000 (20:04 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Mon, 25 Mar 2019 20:04:08 +0000 (20:04 +0000)
50 files changed:
.phpcs.xml
RELEASE-NOTES-1.33
autoload.php
docs/hooks.txt
includes/ActorMigration.php
includes/DefaultSettings.php
includes/Linker.php
includes/MagicWordArray.php
includes/api/ApiFormatBase.php
includes/cache/localisation/LCStoreStaticArray.php
includes/changetags/ChangeTags.php
includes/config/ConfigRepository.php
includes/db/DatabaseOracle.php
includes/db/MWLBFactory.php
includes/diff/DiffEngine.php
includes/filerepo/file/ForeignAPIFile.php
includes/gallery/TraditionalImageGallery.php
includes/installer/DatabaseUpdater.php
includes/libs/objectcache/BagOStuff.php
includes/libs/objectcache/MultiWriteBagOStuff.php
includes/libs/objectcache/RESTBagOStuff.php
includes/libs/rdbms/database/DatabaseMysqli.php
includes/libs/rdbms/lbfactory/LBFactory.php
includes/libs/rdbms/lbfactory/LBFactoryMulti.php
includes/media/MediaHandlerFactory.php
includes/objectcache/ObjectCache.php
includes/page/ImagePage.php
includes/parser/LinkHolderArray.php
includes/parser/Parser.php
includes/poolcounter/PoolCounter.php
includes/poolcounter/PoolCounterNull.php [new file with mode: 0644]
includes/rcfeed/RedisPubSubFeedEngine.php
includes/registration/ExtensionProcessor.php
includes/registration/Processor.php
includes/upload/UploadBase.php
includes/utils/UIDGenerator.php
languages/classes/LanguageKk_cyrl.php
maintenance/cleanupInvalidDbKeys.php
maintenance/includes/BackupDumper.php
maintenance/mysql.php
resources/Resources.php
resources/src/mediawiki.feedback/feedback.css
resources/src/mediawiki.feedback/feedback.js
resources/src/mediawiki.feedback/images/spinner.gif [deleted file]
resources/src/mediawiki.widgets.visibleLengthLimit/mediawiki.widgets.visibleLengthLimit.js
tests/parser/ParserTestRunner.php
tests/phpunit/documentation/ReleaseNotesTest.php
tests/phpunit/includes/cache/MessageCacheTest.php
tests/phpunit/includes/libs/objectcache/BagOStuffTest.php
tests/phpunit/includes/specials/QueryAllSpecialPagesTest.php

index 6934648..d1e54a7 100644 (file)
                <exclude-pattern>*/includes/parser/Preprocessor_Hash\.php</exclude-pattern>
                <exclude-pattern>*/includes/parser/Preprocessor\.php</exclude-pattern>
                <exclude-pattern>*/includes/PathRouter\.php</exclude-pattern>
-               <exclude-pattern>*/includes/poolcounter/PoolCounter\.php</exclude-pattern>
                <exclude-pattern>*/includes/PrefixSearch\.php</exclude-pattern>
                <exclude-pattern>*/includes/profiler/SectionProfiler\.php</exclude-pattern>
                <exclude-pattern>*/includes/search/SearchEngine\.php</exclude-pattern>
index 93d3253..72a468b 100644 (file)
@@ -84,6 +84,8 @@ For notes on 1.32.x and older releases, see HISTORY.
   is no longer a problem, because the code now ensures the timestamp is always
   higher than the previous one. The writes are guarded with CAS logic (check
   and set), which prevents updates that would overlap.
+* $wgDBmysql5 (T196185) - This experimental setting, deprecated in 1.31, has
+  been removed.
 
 === New user-facing features in 1.33 ===
 * (T96041) __EXPECTUNUSEDCATEGORY__ on a category page causes the category
index a69a997..528b7fe 100644 (file)
@@ -1108,10 +1108,10 @@ $wgAutoloadLocalClasses = [
        'PhpXmlBugTester' => __DIR__ . '/includes/installer/PhpBugTests.php',
        'Pingback' => __DIR__ . '/includes/Pingback.php',
        'PoolCounter' => __DIR__ . '/includes/poolcounter/PoolCounter.php',
+       'PoolCounterNull' => __DIR__ . '/includes/poolcounter/PoolCounterNull.php',
        'PoolCounterRedis' => __DIR__ . '/includes/poolcounter/PoolCounterRedis.php',
        'PoolCounterWork' => __DIR__ . '/includes/poolcounter/PoolCounterWork.php',
        'PoolCounterWorkViaCallback' => __DIR__ . '/includes/poolcounter/PoolCounterWorkViaCallback.php',
-       'PoolCounter_Stub' => __DIR__ . '/includes/poolcounter/PoolCounter.php',
        'PoolWorkArticleView' => __DIR__ . '/includes/poolcounter/PoolWorkArticleView.php',
        'PopulateArchiveRevId' => __DIR__ . '/maintenance/populateArchiveRevId.php',
        'PopulateBacklinkNamespace' => __DIR__ . '/maintenance/populateBacklinkNamespace.php',
index 4ef680a..139123d 100644 (file)
@@ -2446,10 +2446,14 @@ $userLang: the user language (Language or StubUserLang object)
 $wikiPage: the WikiPage (object) being saved
 $user: the user (object) saving the article
 $content: the new article content, as a Content object
-$summary: the article summary (comment)
-$isminor: minor flag
-$iswatch: watch flag
-$section: section #
+&$summary: CommentStoreComment object containing the edit comment. Can be replaced with a new one.
+$isminor: Boolean flag specifying if the edit was marked as minor.
+$iswatch: Previously a watch flag. Currently unused, always null.
+$section: Previously the section number being edited. Currently unused, always null.
+$flags: All EDIT_… flags (including EDIT_MINOR) as an integer number. See WikiPage::doEditContent
+  documentation for flags' definition.
+$status: StatusValue object for the hook handlers resulting status. Either set $status->fatal() or
+  return false to abort the save action.
 
 'PageContentSaveComplete': After an article has been updated.
 $wikiPage: WikiPage modified
index 0c33eb9..597b8e7 100644 (file)
@@ -136,11 +136,7 @@ class ActorMigration {
         * @return string[] [ $text, $actor ]
         */
        private static function getFieldNames( $key ) {
-               if ( isset( self::$specialFields[$key] ) ) {
-                       return self::$specialFields[$key];
-               }
-
-               return [ $key . '_text', substr( $key, 0, -5 ) . '_actor' ];
+               return self::$specialFields[$key] ?? [ $key . '_text', substr( $key, 0, -5 ) . '_actor' ];
        }
 
        /**
index 3afa593..7a645a6 100644 (file)
@@ -2114,26 +2114,6 @@ $wgDBerrorLog = false;
  */
 $wgDBerrorLogTZ = false;
 
-/**
- * Set to true to engage MySQL 4.1/5.0 charset-related features;
- * for now will just cause sending of 'SET NAMES=utf8' on connect.
- *
- * @warning THIS IS EXPERIMENTAL!
- *
- * May break if you're not using the table defs from mysql5/tables.sql.
- * May break if you're upgrading an existing wiki if set differently.
- * Broken symptoms likely to include incorrect behavior with page titles,
- * usernames, comments etc containing non-ASCII characters.
- * Might also cause failures on the object cache and other things.
- *
- * Even correct usage may cause failures with Unicode supplementary
- * characters (those not in the Basic Multilingual Plane) unless MySQL
- * has enhanced their Unicode support.
- *
- * @deprecated since 1.31
- */
-$wgDBmysql5 = false;
-
 /**
  * Set true to enable Oracle DCRP (supported from 11gR1 onward)
  *
index 5e07f1e..decc13c 100644 (file)
@@ -1710,12 +1710,8 @@ class Linker {
        static function splitTrail( $trail ) {
                $regex = MediaWikiServices::getInstance()->getContentLanguage()->linkTrail();
                $inside = '';
-               if ( $trail !== '' ) {
-                       $m = [];
-                       if ( preg_match( $regex, $trail, $m ) ) {
-                               $inside = $m[1];
-                               $trail = $m[2];
-                       }
+               if ( $trail !== '' && preg_match( $regex, $trail, $m ) ) {
+                       list( , $inside, $trail ) = $m;
                }
                return [ $inside, $trail ];
        }
index fde32ce..707c644 100644 (file)
@@ -268,10 +268,7 @@ class MagicWordArray {
                        return $hash[1][$text];
                }
                $lc = $this->factory->getContentLanguage()->lc( $text );
-               if ( isset( $hash[0][$lc] ) ) {
-                       return $hash[0][$lc];
-               }
-               return false;
+               return $hash[0][$lc] ?? false;
        }
 
        /**
index e033525..bff9fd0 100644 (file)
@@ -158,11 +158,9 @@ abstract class ApiFormatBase extends ApiBase {
 
                if ( !is_array( $paramSettings ) ) {
                        return $paramSettings;
-               } elseif ( isset( $paramSettings[self::PARAM_DFLT] ) ) {
-                       return $paramSettings[self::PARAM_DFLT];
-               } else {
-                       return null;
                }
+
+               return $paramSettings[self::PARAM_DFLT] ?? null;
        }
 
        /**
index 75c8465..f860146 100644 (file)
@@ -101,8 +101,7 @@ class LCStoreStaticArray implements LCStore {
                        return $encoded;
                }
 
-               $type = $encoded[0];
-               $data = $encoded[1];
+               list( $type, $data ) = $encoded;
 
                switch ( $type ) {
                        case 'a':
index 00eed14..3a93e57 100644 (file)
@@ -766,7 +766,7 @@ class ChangeTags {
                                        // Return nothing.
                                        $conds[] = '0';
                                        break;
-                               };
+                               }
                        }
 
                        if ( $filterTagIds !== [] ) {
index 96dc51c..2874c33 100644 (file)
@@ -71,10 +71,8 @@ class ConfigRepository implements SalvageableService {
                if ( !$this->has( $name, true ) ) {
                        throw new \ConfigException( 'The configuration option ' . $name . ' does not exist.' );
                }
-               if ( isset( $this->configItems['public'][$name] ) ) {
-                       return $this->configItems['public'][$name];
-               }
-               return $this->configItems['private'][$name];
+
+               return $this->configItems['public'][$name] ?? $this->configItems['private'][$name];
        }
 
        /**
index 16bde4b..bc3873d 100644 (file)
@@ -700,14 +700,6 @@ class DatabaseOracle extends Database {
                return new Blob( $b );
        }
 
-       function decodeBlob( $b ) {
-               if ( $b instanceof Blob ) {
-                       $b = $b->fetch();
-               }
-
-               return $b;
-       }
-
        function unionQueries( $sqls, $all ) {
                $glue = ' UNION ALL ';
 
@@ -1350,10 +1342,6 @@ class DatabaseOracle extends Database {
                return 'BITOR(' . $fieldLeft . ', ' . $fieldRight . ')';
        }
 
-       function getServer() {
-               return $this->server;
-       }
-
        public function buildGroupConcatField(
                $delim, $table, $field, $conds = '', $join_conds = []
        ) {
index 6ed693e..9851460 100644 (file)
@@ -122,7 +122,6 @@ abstract class MWLBFactory {
                                                'tablePrefix' => $mainConfig->get( 'DBprefix' ),
                                                'flags' => DBO_DEFAULT,
                                                'sqlMode' => $mainConfig->get( 'SQLMode' ),
-                                               'utf8Mode' => $mainConfig->get( 'DBmysql5' )
                                        ];
 
                                        $lbConf['servers'][$i] = $server;
@@ -142,7 +141,6 @@ abstract class MWLBFactory {
                                        'load' => 1,
                                        'flags' => $flags,
                                        'sqlMode' => $mainConfig->get( 'SQLMode' ),
-                                       'utf8Mode' => $mainConfig->get( 'DBmysql5' )
                                ];
                                if ( in_array( $server['type'], $typesWithSchema, true ) ) {
                                        $server += [ 'schema' => $mainConfig->get( 'DBmwschema' ) ];
@@ -168,7 +166,6 @@ abstract class MWLBFactory {
                                        $lbConf['serverTemplate']['schema'] = $mainConfig->get( 'DBmwschema' );
                                }
                                $lbConf['serverTemplate']['sqlMode'] = $mainConfig->get( 'SQLMode' );
-                               $lbConf['serverTemplate']['utf8Mode'] = $mainConfig->get( 'DBmysql5' );
                        }
                }
 
index edf8444..546a12c 100644 (file)
@@ -456,9 +456,7 @@ class DiffEngine {
 
                // need to store these so we don't lose them when they're
                // overwritten by the recursion
-               $len = $snake[2];
-               $startx = $snake[0];
-               $starty = $snake[1];
+               list( $startx, $starty, $len ) = $snake;
 
                // the middle snake is part of the LCS, store it
                for ( $i = 0; $i < $len; ++$i ) {
index c49810c..3a75720 100644 (file)
@@ -184,11 +184,7 @@ class ForeignAPIFile extends File {
         *   null on error
         */
        public function getExtendedMetadata() {
-               if ( isset( $this->mInfo['extmetadata'] ) ) {
-                       return $this->mInfo['extmetadata'];
-               }
-
-               return null;
+               return $this->mInfo['extmetadata'] ?? null;
        }
 
        /**
index 5ede631..9de7eb8 100644 (file)
@@ -72,11 +72,9 @@ class TraditionalImageGallery extends ImageGalleryBase {
                $lang = $this->getRenderLang();
                # Output each image...
                foreach ( $this->mImages as $pair ) {
+                       // "text" means "caption" here
                        /** @var Title $nt */
-                       $nt = $pair[0];
-                       $text = $pair[1]; # "text" means "caption" here
-                       $alt = $pair[2];
-                       $link = $pair[3];
+                       list( $nt, $text, $alt, $link ) = $pair;
 
                        $descQuery = false;
                        if ( $nt->getNamespace() === NS_FILE ) {
index 7a92807..750f108 100644 (file)
@@ -410,9 +410,7 @@ abstract class DatabaseUpdater {
                $this->updatesSkipped = [];
 
                foreach ( $updates as $funcList ) {
-                       $func = $funcList[0];
-                       $args = $funcList[1];
-                       $origParams = $funcList[2];
+                       list( $func, $args, $origParams ) = $funcList;
                        $func( ...$args );
                        flush();
                        $this->updatesSkipped[] = $origParams;
index e2b0212..4fe64f2 100644 (file)
@@ -278,7 +278,7 @@ abstract class BagOStuff implements IExpiringStore, LoggerAwareInterface {
         * @throws InvalidArgumentException
         */
        public function merge( $key, callable $callback, $exptime = 0, $attempts = 10, $flags = 0 ) {
-               return $this->mergeViaLock( $key, $callback, $exptime, $attempts, $flags );
+               return $this->mergeViaCas( $key, $callback, $exptime, $attempts, $flags );
        }
 
        /**
@@ -311,11 +311,13 @@ abstract class BagOStuff implements IExpiringStore, LoggerAwareInterface {
 
                        // Derive the new value from the old value
                        $value = call_user_func( $callback, $this, $key, $currentValue, $exptime );
+                       $hadNoCurrentValue = ( $currentValue === false );
+                       unset( $currentValue ); // free RAM in case the value is large
 
                        $this->clearLastError();
                        if ( $value === false ) {
                                $success = true; // do nothing
-                       } elseif ( $currentValue === false ) {
+                       } elseif ( $hadNoCurrentValue ) {
                                // Try to create the key, failing if it gets created in the meantime
                                $success = $this->add( $key, $value, $exptime, $flags );
                        } else {
@@ -369,58 +371,6 @@ abstract class BagOStuff implements IExpiringStore, LoggerAwareInterface {
                return $success;
        }
 
-       /**
-        * @see BagOStuff::merge()
-        *
-        * @param string $key
-        * @param callable $callback Callback method to be executed
-        * @param int $exptime Either an interval in seconds or a unix timestamp for expiry
-        * @param int $attempts The amount of times to attempt a merge in case of failure
-        * @param int $flags Bitfield of BagOStuff::WRITE_* constants
-        * @return bool Success
-        */
-       protected function mergeViaLock( $key, $callback, $exptime = 0, $attempts = 10, $flags = 0 ) {
-               if ( $attempts <= 1 ) {
-                       $timeout = 0; // clearly intended to be "non-blocking"
-               } else {
-                       $timeout = 3;
-               }
-
-               if ( !$this->lock( $key, $timeout ) ) {
-                       return false;
-               }
-
-               $this->clearLastError();
-               $reportDupes = $this->reportDupes;
-               $this->reportDupes = false;
-               $currentValue = $this->get( $key, self::READ_LATEST );
-               $this->reportDupes = $reportDupes;
-
-               if ( $this->getLastError() ) {
-                       $this->logger->warning(
-                               __METHOD__ . ' failed due to I/O error on get() for {key}.',
-                               [ 'key' => $key ]
-                       );
-
-                       $success = false;
-               } else {
-                       // Derive the new value from the old value
-                       $value = call_user_func( $callback, $this, $key, $currentValue, $exptime );
-                       if ( $value === false ) {
-                               $success = true; // do nothing
-                       } else {
-                               $success = $this->set( $key, $value, $exptime, $flags ); // set the new value
-                       }
-               }
-
-               if ( !$this->unlock( $key ) ) {
-                       // this should never happen
-                       trigger_error( "Could not release lock for key '$key'." );
-               }
-
-               return $success;
-       }
-
        /**
         * Change the expiration on a key if it exists
         *
index 5cf9de4..2d3eed5 100644 (file)
@@ -104,7 +104,7 @@ class MultiWriteBagOStuff extends BagOStuff {
                if ( ( $flags & self::READ_LATEST ) == self::READ_LATEST ) {
                        // If the latest write was a delete(), we do NOT want to fallback
                        // to the other tiers and possibly see the old value. Also, this
-                       // is used by mergeViaLock(), which only needs to hit the primary.
+                       // is used by merge(), which only needs to hit the primary.
                        return $this->caches[0]->get( $key, $flags );
                }
 
index c127ec6..7e578f9 100644 (file)
@@ -84,12 +84,15 @@ class RESTBagOStuff extends BagOStuff {
                $this->client->setLogger( $logger );
        }
 
-       /**
-        * @param string $key
-        * @param int $flags Bitfield of BagOStuff::READ_* constants [optional]
-        * @return mixed Returns false on failure and if the item does not exist
-        */
        protected function doGet( $key, $flags = 0 ) {
+               $casToken = null;
+
+               return $this->getWithToken( $key, $casToken, $flags );
+       }
+
+       protected function getWithToken( $key, &$casToken, $flags = 0 ) {
+               $casToken = null;
+
                $req = [
                        'method' => 'GET',
                        'url' => $this->url . rawurlencode( $key ),
@@ -98,7 +101,11 @@ class RESTBagOStuff extends BagOStuff {
                list( $rcode, $rdesc, $rhdrs, $rbody, $rerr ) = $this->client->run( $req );
                if ( $rcode === 200 ) {
                        if ( is_string( $rbody ) ) {
-                               return unserialize( $rbody );
+                               $value = unserialize( $rbody );
+                               /// @FIXME: use some kind of hash or UUID header as CAS token
+                               $casToken = ( $value !== false ) ? $rbody : null;
+
+                               return $value;
                        }
                        return false;
                }
@@ -108,22 +115,6 @@ class RESTBagOStuff extends BagOStuff {
                return false;
        }
 
-       /**
-        * Handle storage error
-        * @param string $msg Error message
-        * @param int $rcode Error code from client
-        * @param string $rerr Error message from client
-        * @return false
-        */
-       protected function handleError( $msg, $rcode, $rerr ) {
-               $this->logger->error( "$msg : ({code}) {error}", [
-                       'code' => $rcode,
-                       'error' => $rerr
-               ] );
-               $this->setLastError( $rcode === 0 ? self::ERR_UNREACHABLE : self::ERR_UNEXPECTED );
-               return false;
-       }
-
        public function set( $key, $value, $exptime = 0, $flags = 0 ) {
                // @TODO: respect WRITE_SYNC (e.g. EACH_QUORUM)
                // @TODO: respect $exptime
@@ -172,4 +163,24 @@ class RESTBagOStuff extends BagOStuff {
 
                return false;
        }
+
+       public function merge( $key, callable $callback, $exptime = 0, $attempts = 10, $flags = 0 ) {
+               return $this->mergeViaCas( $key, $callback, $exptime, $attempts, $flags );
+       }
+
+       /**
+        * Handle storage error
+        * @param string $msg Error message
+        * @param int $rcode Error code from client
+        * @param string $rerr Error message from client
+        * @return false
+        */
+       protected function handleError( $msg, $rcode, $rerr ) {
+               $this->logger->error( "$msg : ({code}) {error}", [
+                       'code' => $rcode,
+                       'error' => $rerr
+               ] );
+               $this->setLastError( $rcode === 0 ? self::ERR_UNREACHABLE : self::ERR_UNEXPECTED );
+               return false;
+       }
 }
index 1c4ed56..15eeccf 100644 (file)
@@ -78,9 +78,7 @@ class DatabaseMysqli extends DatabaseMysqlBase {
                } elseif ( substr_count( $realServer, ':' ) == 1 ) {
                        // If we have a colon and something that's not a port number
                        // inside the hostname, assume it's the socket location
-                       $hostAndSocket = explode( ':', $realServer, 2 );
-                       $realServer = $hostAndSocket[0];
-                       $socket = $hostAndSocket[1];
+                       list( $realServer, $socket ) = explode( ':', $realServer, 2 );
                }
 
                $mysqli = mysqli_init();
index 007ac20..3a8f2e1 100644 (file)
@@ -654,7 +654,7 @@ abstract class LBFactory implements ILBFactory {
        }
 
        public function closeAll() {
-               $this->forEachLBCallMethod( 'closeAll', [] );
+               $this->forEachLBCallMethod( 'closeAll' );
        }
 
        public function setAgentName( $agent ) {
index 189ceee..aec99f4 100644 (file)
@@ -89,9 +89,6 @@ class LBFactoryMulti extends LBFactory {
         */
        private $readOnlyBySection = [];
 
-       /** @var array Load balancer factory configuration */
-       private $conf;
-
        /** @var LoadBalancer[] */
        private $mainLBs = [];
 
@@ -166,7 +163,6 @@ class LBFactoryMulti extends LBFactory {
        public function __construct( array $conf ) {
                parent::__construct( $conf );
 
-               $this->conf = $conf;
                $required = [ 'sectionsByDB', 'sectionLoads', 'serverTemplate' ];
                $optional = [ 'groupLoadsBySection', 'groupLoadsByDB', 'hostsByName',
                        'externalLoads', 'externalTemplateOverrides', 'templateOverridesByServer',
index 543dc80..82e8d1f 100644 (file)
@@ -66,11 +66,7 @@ class MediaHandlerFactory {
        }
 
        protected function getHandlerClass( $type ) {
-               if ( isset( $this->registry[$type] ) ) {
-                       return $this->registry[$type];
-               } else {
-                       return false;
-               }
+               return $this->registry[$type] ?? false;
        }
 
        /**
index dc8b146..fed0854 100644 (file)
@@ -238,7 +238,6 @@ class ObjectCache {
                global $wgMainCacheType, $wgMessageCacheType, $wgParserCacheType;
                $candidates = [ $wgMainCacheType, $wgMessageCacheType, $wgParserCacheType ];
                foreach ( $candidates as $candidate ) {
-                       $cache = false;
                        if ( $candidate !== CACHE_NONE && $candidate !== CACHE_ANYTHING ) {
                                $cache = self::getInstance( $candidate );
                                // CACHE_ACCEL might default to nothing if no APCu
index 66804bc..60237ff 100644 (file)
@@ -321,9 +321,7 @@ class ImagePage extends Article {
                $dirmark = $lang->getDirMarkEntity();
                $request = $this->getContext()->getRequest();
 
-               $max = $this->getImageLimitsFromOption( $user, 'imagesize' );
-               $maxWidth = $max[0];
-               $maxHeight = $max[1];
+               list( $maxWidth, $maxHeight ) = $this->getImageLimitsFromOption( $user, 'imagesize' );
 
                if ( $this->displayImg->exists() ) {
                        # image
@@ -1029,7 +1027,7 @@ EOT
         *
         * @param User $user
         * @param string $optionName Name of a option to check, typically imagesize or thumbsize
-        * @return array
+        * @return int[]
         * @since 1.21
         */
        public function getImageLimitsFromOption( $user, $optionName ) {
index 078c819..6416449 100644 (file)
@@ -632,8 +632,7 @@ class LinkHolderArray {
         * @private
         */
        public function replaceTextCallback( $matches ) {
-               $type = $matches[1];
-               $key = $matches[2];
+               list( , $type, $key ) = $matches;
                if ( $type == 'LINK' ) {
                        list( $ns, $index ) = explode( ':', $key, 2 );
                        if ( isset( $this->internals[$ns][$index]['text'] ) ) {
index 546152f..0440e89 100644 (file)
@@ -1045,10 +1045,7 @@ class Parser {
                                $inside = $p[5];
                        } else {
                                # tag
-                               $element = $p[1];
-                               $attributes = $p[2];
-                               $close = $p[3];
-                               $inside = $p[4];
+                               list( , $element, $attributes, $close, $inside ) = $p;
                        }
 
                        $marker = self::MARKER_PREFIX . "-$element-" . sprintf( '%08X', $n++ ) . self::MARKER_SUFFIX;
@@ -1072,8 +1069,7 @@ class Parser {
                                        $tail = '';
                                        $text = '';
                                } else {
-                                       $tail = $q[1];
-                                       $text = $q[2];
+                                       list( , $tail, $text ) = $q;
                                }
                        }
 
@@ -2240,8 +2236,7 @@ class Parser {
 
                        if ( $useLinkPrefixExtension ) {
                                if ( preg_match( $e2, $s, $m ) ) {
-                                       $prefix = $m[2];
-                                       $s = $m[1];
+                                       list( , $s, $prefix ) = $m;
                                } else {
                                        $prefix = '';
                                }
index ba0b4cb..060faec 100644 (file)
@@ -39,7 +39,7 @@
  * that start with "nowait:". However, only 0 timeouts (non-blocking requests)
  * can be used with "nowait:" keys.
  *
- * By default PoolCounter_Stub is used, which provides no locking. You
+ * By default PoolCounterNull is used, which provides no locking. You
  * can get a useful one in the PoolCounter extension.
  */
 abstract class PoolCounter {
@@ -111,7 +111,7 @@ abstract class PoolCounter {
        public static function factory( $type, $key ) {
                global $wgPoolCounterConf;
                if ( !isset( $wgPoolCounterConf[$type] ) ) {
-                       return new PoolCounter_Stub;
+                       return new PoolCounterNull;
                }
                $conf = $wgPoolCounterConf[$type];
                $class = $conf['class'];
@@ -208,23 +208,3 @@ abstract class PoolCounter {
                return $type . ':' . ( hexdec( substr( sha1( $key ), 0, 4 ) ) % $slots );
        }
 }
-
-// phpcs:ignore Squiz.Classes.ValidClassName.NotCamelCaps
-class PoolCounter_Stub extends PoolCounter {
-
-       public function __construct() {
-               /* No parameters needed */
-       }
-
-       public function acquireForMe() {
-               return Status::newGood( PoolCounter::LOCKED );
-       }
-
-       public function acquireForAnyone() {
-               return Status::newGood( PoolCounter::LOCKED );
-       }
-
-       public function release() {
-               return Status::newGood( PoolCounter::RELEASED );
-       }
-}
diff --git a/includes/poolcounter/PoolCounterNull.php b/includes/poolcounter/PoolCounterNull.php
new file mode 100644 (file)
index 0000000..95a5057
--- /dev/null
@@ -0,0 +1,44 @@
+<?php
+/**
+ * Provides of semaphore semantics for restricting the number
+ * of workers that may be concurrently performing the same task.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ */
+
+/**
+ * A default PoolCounter, which provides no locking.
+ */
+class PoolCounterNull extends PoolCounter {
+
+       public function __construct() {
+               /* No parameters needed */
+       }
+
+       public function acquireForMe() {
+               return Status::newGood( PoolCounter::LOCKED );
+       }
+
+       public function acquireForAnyone() {
+               return Status::newGood( PoolCounter::LOCKED );
+       }
+
+       public function release() {
+               return Status::newGood( PoolCounter::RELEASED );
+       }
+}
index 8a3aa0c..c954df1 100644 (file)
@@ -37,7 +37,7 @@
  *
  * @since 1.22
  */
-class RedisPubSubFeedEngine extends RCFeedEngine {
+class RedisPubSubFeedEngine extends FormattedRCFeed {
 
        /**
         * @see FormattedRCFeed::send
@@ -68,8 +68,8 @@ class RedisPubSubFeedEngine extends RCFeedEngine {
                if ( $conn !== false ) {
                        $conn->publish( $channel, $line );
                        return true;
-               } else {
-                       return false;
                }
+
+               return false;
        }
 }
index 1d3fd86..b474ddc 100644 (file)
@@ -189,7 +189,6 @@ class ExtensionProcessor implements Processor {
         * @param string $path
         * @param array $info
         * @param int $version manifest_version for info
-        * @return array
         */
        public function extractInfo( $path, array $info, $version ) {
                $dir = dirname( $path );
index 636d3b3..68ba413 100644 (file)
@@ -17,7 +17,6 @@ interface Processor {
         * @param string $path Absolute path of JSON file
         * @param array $info
         * @param int $version manifest_version for info
-        * @return array "credits" information to store
         */
        public function extractInfo( $path, array $info, $version );
 
index c42584c..d00ad97 100644 (file)
@@ -947,8 +947,8 @@ abstract class UploadBase {
                 */
                list( $partname, $ext ) = $this->splitExtensions( $this->mFilteredName );
 
-               if ( count( $ext ) ) {
-                       $this->mFinalExtension = trim( $ext[count( $ext ) - 1] );
+               if ( $ext !== [] ) {
+                       $this->mFinalExtension = trim( end( $ext ) );
                } else {
                        $this->mFinalExtension = '';
 
index 15c0cf9..65b50e2 100644 (file)
@@ -137,8 +137,7 @@ class UIDGenerator {
                        $time = $info['time'];
                        $counter = $info['offsetCounter'];
                } else {
-                       $time = $info[0];
-                       $counter = $info[1];
+                       list( $time, $counter ) = $info;
                }
                // Take the 46 LSBs of "milliseconds since epoch"
                $id_bin = $this->millisecondsSinceEpochBinary( $time );
@@ -192,9 +191,7 @@ class UIDGenerator {
                        $counter = $info['offsetCounter'];
                        $clkSeq = $info['clkSeq'];
                } else {
-                       $time = $info[0];
-                       $counter = $info[1];
-                       $clkSeq = $info[2];
+                       list( $time, $counter, $clkSeq ) = $info;
                }
                // Take the 46 LSBs of "milliseconds since epoch"
                $id_bin = $this->millisecondsSinceEpochBinary( $time );
index d695be1..a89dbc2 100644 (file)
@@ -63,9 +63,7 @@ class LanguageKk_cyrl extends Language {
                $secondPerson = [ "з" ]; // 1st plural, 2nd formal
                $thirdPerson = [ "ы", "і" ]; // 3rd
 
-               $lastLetter = $this->lastLetter( $word, $allVowels );
-               $wordEnding =& $lastLetter[0];
-               $wordLastVowel =& $lastLetter[1];
+               list( $wordEnding, $wordLastVowel ) = $this->lastLetter( $word, $allVowels );
 
                // Now convert the word
                switch ( $case ) {
@@ -297,9 +295,7 @@ class LanguageKk_cyrl extends Language {
                $secondPerson = [ "z" ]; // 1st plural, 2nd formal
                $thirdPerson = [ "ı", "i" ]; // 3rd
 
-               $lastLetter = $this->lastLetter( $word, $allVowels );
-               $wordEnding =& $lastLetter[0];
-               $wordLastVowel =& $lastLetter[1];
+               list( $wordEnding, $wordLastVowel ) = $this->lastLetter( $word, $allVowels );
 
                // Now convert the word
                switch ( $case ) {
@@ -531,9 +527,7 @@ class LanguageKk_cyrl extends Language {
                $secondPerson = [ "ز" ]; // 1st plural, 2nd formal
                $thirdPerson = [ "ى", "ٸ" ]; // 3rd
 
-               $lastLetter = $this->lastLetter( $word, $allVowels );
-               $wordEnding = $lastLetter[0];
-               $wordLastVowel = $lastLetter[1];
+               list( $wordEnding, $wordLastVowel ) = $this->lastLetter( $word, $allVowels );
 
                // Now convert the word
                switch ( $case ) {
@@ -737,7 +731,7 @@ class LanguageKk_cyrl extends Language {
 
        /**
         * @param string $word
-        * @param array $allVowels
+        * @param string[] $allVowels
         * @return array
         */
        function lastLetter( $word, $allVowels ) {
index abae4f4..eb45cfc 100644 (file)
@@ -121,8 +121,7 @@ TEXT
         * @param array $tableParams A child array of self::$tables
         */
        protected function cleanupTable( $tableParams ) {
-               $table = $tableParams[0];
-               $prefix = $tableParams[1];
+               list( $table, $prefix ) = $tableParams;
                $idField = $tableParams['idField'] ?? "{$prefix}_id";
                $nsField = $tableParams['nsField'] ?? "{$prefix}_namespace";
                $titleField = $tableParams['titleField'] ?? "{$prefix}_title";
index 3ae7f48..0b450a6 100644 (file)
@@ -26,6 +26,7 @@
  */
 
 require_once __DIR__ . '/../Maintenance.php';
+require_once __DIR__ . '/../../includes/export/WikiExporter.php';
 
 use MediaWiki\MediaWikiServices;
 use Wikimedia\Rdbms\LoadBalancer;
@@ -163,8 +164,7 @@ abstract class BackupDumper extends Maintenance {
 
                $options = $this->orderedOptions;
                foreach ( $options as $arg ) {
-                       $opt = $arg[0];
-                       $param = $arg[1];
+                       list( $opt, $param ) = $arg;
 
                        switch ( $opt ) {
                                case 'plugin':
index 34a6cb6..c1e403c 100644 (file)
@@ -137,9 +137,7 @@ class MysqlMaintenance extends Maintenance {
                } elseif ( substr_count( $realServer, ':' ) == 1 ) {
                        // If we have a colon and something that's not a port number
                        // inside the hostname, assume it's the socket location
-                       $hostAndSocket = explode( ':', $realServer, 2 );
-                       $realServer = $hostAndSocket[0];
-                       $socket = $hostAndSocket[1];
+                       list( $realServer, $socket ) = explode( ':', $realServer, 2 );
                }
 
                if ( $dbName === false ) {
index 5e5f308..b2d0ad2 100644 (file)
@@ -592,6 +592,7 @@ return [
                'group' => 'jquery.ui',
        ],
        'jquery.ui.spinner' => [
+               'deprecated' => 'Please use "jquery.spinner" instead.',
                'scripts' => 'resources/lib/jquery.ui/jquery.ui.spinner.js',
                'dependencies' => [
                        'jquery.ui.core',
index 92e1d04..c2d4835 100644 (file)
@@ -1,13 +1,3 @@
-.feedback-spinner {
-       display: inline-block;
-       zoom: 1;
-       *display: inline; /* IE7 and below */ /* stylelint-disable declaration-block-no-duplicate-properties */
-       /* @embed */
-       background: url( images/spinner.gif );
-       width: 18px;
-       height: 18px;
-}
-
 .mw-feedbackDialog-welcome-message,
 .mw-feedbackDialog-feedback-terms {
        line-height: 1.4;
index 5b73e7c..3ffc496 100644 (file)
                        padded: true
                } );
 
-               this.$spinner = $( '<div>' )
-                       .addClass( 'feedback-spinner' );
-
                // Feedback form
                this.feedbackMessageLabel = new OO.ui.LabelWidget( {
                        classes: [ 'mw-feedbackDialog-welcome-message' ]
diff --git a/resources/src/mediawiki.feedback/images/spinner.gif b/resources/src/mediawiki.feedback/images/spinner.gif
deleted file mode 100644 (file)
index aed0ea4..0000000
Binary files a/resources/src/mediawiki.feedback/images/spinner.gif and /dev/null differ
index 63da95a..453bf03 100644 (file)
         *
         * @param {OO.ui.TextInputWidget} textInputWidget Text input widget
         * @param {number} [limit] Byte limit, defaults to $input's maxlength
+        * @param {Function} [filterFunction] Function to call on the string before assessing the length.
         */
-       mw.widgets.visibleByteLimit = function ( textInputWidget, limit ) {
+       mw.widgets.visibleByteLimit = function ( textInputWidget, limit, filterFunction ) {
                limit = limit || +textInputWidget.$input.attr( 'maxlength' );
+               if ( !filterFunction || typeof filterFunction !== 'function' ) {
+                       filterFunction = undefined;
+               }
 
                function updateCount() {
-                       var remaining = limit - byteLength( textInputWidget.getValue() );
+                       var value = textInputWidget.getValue(),
+                               remaining;
+                       if ( filterFunction ) {
+                               value = filterFunction( value );
+                       }
+                       remaining = limit - byteLength( value );
                        if ( remaining > 99 ) {
                                remaining = '';
                        } else {
@@ -32,7 +41,7 @@
                updateCount();
 
                // Actually enforce limit
-               textInputWidget.$input.byteLimit( limit );
+               textInputWidget.$input.byteLimit( limit, filterFunction );
        };
 
        /**
         * Uses jQuery#codePointLimit to enforce the limit.
         *
         * @param {OO.ui.TextInputWidget} textInputWidget Text input widget
-        * @param {number} [limit] Byte limit, defaults to $input's maxlength
+        * @param {number} [limit] Code point limit, defaults to $input's maxlength
+        * @param {Function} [filterFunction] Function to call on the string before assessing the length.
         */
-       mw.widgets.visibleCodePointLimit = function ( textInputWidget, limit ) {
+       mw.widgets.visibleCodePointLimit = function ( textInputWidget, limit, filterFunction ) {
                limit = limit || +textInputWidget.$input.attr( 'maxlength' );
+               if ( !filterFunction || typeof filterFunction !== 'function' ) {
+                       filterFunction = undefined;
+               }
 
                function updateCount() {
-                       var remaining = limit - codePointLength( textInputWidget.getValue() );
+                       var value = textInputWidget.getValue(),
+                               remaining;
+                       if ( filterFunction ) {
+                               value = filterFunction( value );
+                       }
+                       remaining = limit - codePointLength( value );
                        if ( remaining > 99 ) {
                                remaining = '';
                        } else {
@@ -60,7 +78,7 @@
                updateCount();
 
                // Actually enforce limit
-               textInputWidget.$input.codePointLimit( limit );
+               textInputWidget.$input.codePointLimit( limit, filterFunction );
        };
 
 }() );
index 699de95..1c93261 100644 (file)
@@ -938,12 +938,7 @@ class ParserTestRunner {
         */
        private static function getOptionValue( $key, $opts, $default ) {
                $key = strtolower( $key );
-
-               if ( isset( $opts[$key] ) ) {
-                       return $opts[$key];
-               } else {
-                       return $default;
-               }
+               return $opts[$key] ?? $default;
        }
 
        /**
index 019a13e..d8d0fdc 100644 (file)
@@ -49,16 +49,13 @@ class ReleaseNotesTest extends MediaWikiTestCase {
                        "$type file '$fileName' is inaccessible."
                );
 
-               $lines = count( $file );
-
-               for ( $i = 0; $i < $lines; $i++ ) {
-                       $line = $file[$i];
-
+               foreach ( $file as $i => $line ) {
+                       $num = $i + 1;
                        $this->assertLessThanOrEqual(
                                // FILE_IGNORE_NEW_LINES drops the \n at the EOL, so max length is 80 not 81.
                                80,
                                mb_strlen( $line ),
-                               "$type file '$fileName' line $i is longer than 80 chars:\n\t'$line'"
+                               "$type file '$fileName' line $num, is longer than 80 chars:\n\t'$line'"
                        );
                }
        }
index d8330ef..b03a309 100644 (file)
@@ -223,8 +223,6 @@ class MessageCacheTest extends MediaWikiLangTestCase {
 
        /**
         * Regression test for T218918
-        * @group Broken
-        * @fixme Disabled per https://phabricator.wikimedia.org/T219042
         */
        public function testLoadFromDB_fetchLatestRevision() {
                // Create three revisions of the same message page.
@@ -239,7 +237,7 @@ class MessageCacheTest extends MediaWikiLangTestCase {
                $importRevision = new WikiRevision( new HashConfig() );
                $importRevision->setTitle( $r3->getTitle() );
                $importRevision->setComment( 'Imported edit' );
-               $importRevision->setTimestamp( '19991122334455' );
+               $importRevision->setTimestamp( '19991122001122' );
                $importRevision->setText( 'IMPORTED OLD TEST' );
                $importRevision->setUsername( 'Alan Smithee' );
 
index b68ffaf..3d8c9cb 100644 (file)
@@ -65,20 +65,10 @@ class BagOStuffTest extends MediaWikiTestCase {
 
        /**
         * @covers BagOStuff::merge
-        * @covers BagOStuff::mergeViaLock
         * @covers BagOStuff::mergeViaCas
         */
        public function testMerge() {
                $key = $this->cache->makeKey( self::TEST_KEY );
-               $locks = false;
-               $checkLockingCallback = function ( BagOStuff $cache, $key, $oldVal ) use ( &$locks ) {
-                       $locks = $cache->get( "$key:lock" );
-
-                       return false;
-               };
-
-               $this->cache->merge( $key, $checkLockingCallback, 5 );
-               $this->assertFalse( $this->cache->get( $key ) );
 
                $calls = 0;
                $casRace = false; // emulate a race
@@ -103,31 +93,19 @@ class BagOStuffTest extends MediaWikiTestCase {
                $this->assertEquals( 'mergedmerged', $this->cache->get( $key ) );
 
                $calls = 0;
-               if ( $locks ) {
-                       // merge were something else already was merging (e.g. had the lock)
-                       $this->cache->lock( $key );
-                       $this->assertFalse(
-                               $this->cache->merge( $key, $callback, 5, 1 ),
-                               'Non-blocking merge (locking)'
-                       );
-                       $this->cache->unlock( $key );
-                       $this->assertEquals( 0, $calls );
-               } else {
-                       $casRace = true;
-                       $this->assertFalse(
-                               $this->cache->merge( $key, $callback, 5, 1 ),
-                               'Non-blocking merge (CAS)'
-                       );
-                       $this->assertEquals( 1, $calls );
-               }
+               $casRace = true;
+               $this->assertFalse(
+                       $this->cache->merge( $key, $callback, 5, 1 ),
+                       'Non-blocking merge (CAS)'
+               );
+               $this->assertEquals( 1, $calls );
        }
 
        /**
         * @covers BagOStuff::merge
-        * @covers BagOStuff::mergeViaLock
         * @dataProvider provideTestMerge_fork
         */
-       public function testMerge_fork( $exists, $winsLocking, $resLocking, $resCAS ) {
+       public function testMerge_fork( $exists, $childWins, $resCAS ) {
                $key = $this->cache->makeKey( self::TEST_KEY );
                $pCallback = function ( BagOStuff $cache, $key, $oldVal ) {
                        return ( $oldVal === false ) ? 'init-parent' : $oldVal . '-merged-parent';
@@ -153,16 +131,12 @@ class BagOStuffTest extends MediaWikiTestCase {
                $fork &= !$this->cache instanceof MultiWriteBagOStuff;
                if ( $fork ) {
                        $pid = null;
-                       $locked = false;
                        // Function to start merge(), run another merge() midway through, then finish
-                       $func = function ( BagOStuff $cache, $key, $cur )
-                               use ( $pCallback, $cCallback, &$pid, &$locked )
-                       {
+                       $func = function ( $cache, $key, $cur ) use ( $pCallback, $cCallback, &$pid ) {
                                $pid = pcntl_fork();
                                if ( $pid == -1 ) {
                                        return false;
                                } elseif ( $pid ) {
-                                       $locked = $cache->get( "$key:lock" ); // parent has lock?
                                        pcntl_wait( $status );
 
                                        return $pCallback( $cache, $key, $cur );
@@ -182,15 +156,9 @@ class BagOStuffTest extends MediaWikiTestCase {
                                return; // can't fork, ignore this test...
                        }
 
-                       if ( $locked ) {
-                               // merge succeed since child was locked out
-                               $this->assertEquals( $winsLocking, $merged );
-                               $this->assertEquals( $this->cache->get( $key ), $resLocking );
-                       } else {
-                               // merge has failed because child process was merging (and we only attempted once)
-                               $this->assertEquals( !$winsLocking, $merged );
-                               $this->assertEquals( $this->cache->get( $key ), $resCAS );
-                       }
+                       // merge has failed because child process was merging (and we only attempted once)
+                       $this->assertEquals( !$childWins, $merged );
+                       $this->assertEquals( $this->cache->get( $key ), $resCAS );
                } else {
                        $this->markTestSkipped( 'No pcntl methods available' );
                }
@@ -198,9 +166,9 @@ class BagOStuffTest extends MediaWikiTestCase {
 
        function provideTestMerge_fork() {
                return [
-                       // (already exists, parent wins if locking, result if locking, result if CAS)
-                       [ false, true, 'init-parent', 'init-child' ],
-                       [ true, true, 'x-merged-parent', 'x-merged-child' ]
+                       // (already exists, child wins CAS, result of CAS)
+                       [ false, true, 'init-child' ],
+                       [ true, true, 'x-merged-child' ]
                ];
        }
 
index 4a171df..58f83de 100644 (file)
@@ -42,8 +42,7 @@ class QueryAllSpecialPagesTest extends MediaWikiTestCase {
                parent::__construct();
 
                foreach ( QueryPage::getPages() as $page ) {
-                       $class = $page[0];
-                       $name = $page[1];
+                       list( $class, $name ) = $page;
                        if ( !in_array( $class, $this->manualTest ) ) {
                                $this->queryPages[$class] =
                                        MediaWikiServices::getInstance()->getSpecialPageFactory()->getPage( $name );