Merge "Fix DatabaseSqlite IDEA warnings"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 25 Oct 2016 20:27:57 +0000 (20:27 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 25 Oct 2016 20:27:57 +0000 (20:27 +0000)
22 files changed:
.gitreview
RELEASE-NOTES-1.28
includes/EditPage.php
includes/libs/rdbms/database/DatabasePostgres.php
includes/libs/rdbms/lbfactory/ILBFactory.php
includes/libs/rdbms/lbfactory/LBFactory.php
includes/libs/rdbms/lbfactory/LBFactoryMulti.php
includes/libs/rdbms/lbfactory/LBFactorySimple.php
includes/libs/rdbms/lbfactory/LBFactorySingle.php
includes/libs/rdbms/loadbalancer/LoadBalancerSingle.php
includes/objectcache/ObjectCache.php
includes/parser/CoreParserFunctions.php
maintenance/Maintenance.php
maintenance/jsduck/categories.json
maintenance/update.php
resources/src/mediawiki/mediawiki.js
resources/src/mediawiki/mediawiki.storage.js
resources/src/mediawiki/mediawiki.user.js
tests/qunit/data/testrunner.js
tests/qunit/suites/resources/mediawiki/mediawiki.loader.test.js
tests/qunit/suites/resources/mediawiki/mediawiki.test.js
tests/qunit/suites/resources/mediawiki/mediawiki.user.test.js

index 0ec44b8..148be02 100644 (file)
@@ -2,5 +2,5 @@
 host=gerrit.wikimedia.org
 port=29418
 project=mediawiki/core.git
-defaultbranch=master
+track=1
 defaultrebase=0
index 4e445a5..a2a986f 100644 (file)
@@ -223,6 +223,8 @@ changes to languages because of Phabricator reports.
   Instead of --keep-uploads, use the same option to parserTests.php, but you
   must specify a directory with --upload-dir.
 * The 'jquery.arrowSteps' ResourceLoader module is now deprecated.
+* (T62604) Core parser functions returning a number now format the number according
+  to the page content language, not wiki content language.
 * IP::isConfiguredProxy() and IP::isTrustedProxy() were removed. Callers should
   migrate to using the same functions on a ProxyLookup instance, obtainable from
   MediaWikiServices.
index 770a74e..e8ea20f 100644 (file)
@@ -408,6 +408,11 @@ class EditPage {
         */
        protected $context;
 
+       /**
+        * @var bool Whether an old revision is edited
+        */
+       private $isOldRev = false;
+
        /**
         * @param Article $article
         */
@@ -2968,6 +2973,7 @@ ERROR;
                                        if ( !$revision->isCurrent() ) {
                                                $this->mArticle->setOldSubtitle( $revision->getId() );
                                                $wgOut->addWikiMsg( 'editingold' );
+                                               $this->isOldRev = true;
                                        }
                                } elseif ( $this->mTitle->exists() ) {
                                        // Something went wrong
@@ -3278,6 +3284,10 @@ HTML
                                        $classes[] = 'mw-textarea-cprotected';
                                }
                        }
+                       # Is an old revision being edited?
+                       if ( $this->isOldRev ) {
+                               $classes[] = 'mw-textarea-oldrev';
+                       }
 
                        $attribs = [ 'tabindex' => 1 ];
 
index 016b9cd..7acd8dc 100644 (file)
@@ -1087,7 +1087,7 @@ __INDEXATTR__;
                if ( !is_array( $types ) ) {
                        $types = [ $types ];
                }
-               if ( !$schema ) {
+               if ( $schema === false ) {
                        $schema = $this->getCoreSchema();
                }
                $table = $this->realTableName( $table, 'raw' );
@@ -1236,7 +1236,6 @@ SQL;
 
        function strencode( $s ) {
                // Should not be called by us
-
                return pg_escape_string( $this->getBindingHandle(), $s );
        }
 
index 9c9f18d..ff1bd43 100644 (file)
@@ -86,28 +86,25 @@ interface ILBFactory {
 
        /**
         * Create a new load balancer for external storage. The resulting object will be
-        * untracked, not chronology-protected, and the caller is responsible for
-        * cleaning it up.
+        * untracked, not chronology-protected, and the caller is responsible for cleaning it up.
         *
         * This method is for only advanced usage and callers should almost always use
         * getExternalLB() instead. This method can be useful when a table is used as a
         * key/value store. In that cases, one might want to query it in autocommit mode
         * (DBO_TRX off) but still use DBO_TRX transaction rounds on other tables.
         *
-        * @param string $cluster External storage cluster, or false for core
-        * @param bool|string $domain Domain ID, or false for the current domain
+        * @param string $cluster External storage cluster name
         * @return ILoadBalancer
         */
-       public function newExternalLB( $cluster, $domain = false );
+       public function newExternalLB( $cluster );
 
        /**
         * Get a cached (tracked) load balancer for external storage
         *
-        * @param string $cluster External storage cluster, or false for core
-        * @param bool|string $domain Domain ID, or false for the current domain
+        * @param string $cluster External storage cluster name
         * @return ILoadBalancer
         */
-       public function getExternalLB( $cluster, $domain = false );
+       public function getExternalLB( $cluster );
 
        /**
         * Execute a function for each tracked load balancer
index f3a3275..d21289b 100644 (file)
@@ -153,18 +153,16 @@ abstract class LBFactory implements ILBFactory {
        /**
         * @see ILBFactory::newExternalLB()
         * @param string $cluster
-        * @param bool $domain
         * @return LoadBalancer
         */
-       abstract public function newExternalLB( $cluster, $domain = false );
+       abstract public function newExternalLB( $cluster );
 
        /**
         * @see ILBFactory::getExternalLB()
         * @param string $cluster
-        * @param bool $domain
         * @return LoadBalancer
         */
-       abstract public function getExternalLB( $cluster, $domain = false );
+       abstract public function getExternalLB( $cluster );
 
        /**
         * Call a method of each tracked load balancer
index 83ca650..a7cc16c 100644 (file)
@@ -255,13 +255,7 @@ class LBFactoryMulti extends LBFactory {
                return $this->mainLBs[$section];
        }
 
-       /**
-        * @param string $cluster
-        * @param DatabaseDomain|string|bool $domain Domain ID, or false for the current domain
-        * @throws InvalidArgumentException
-        * @return LoadBalancer
-        */
-       public function newExternalLB( $cluster, $domain = false ) {
+       public function newExternalLB( $cluster ) {
                if ( !isset( $this->externalLoads[$cluster] ) ) {
                        throw new InvalidArgumentException( __METHOD__ . ": Unknown cluster \"$cluster\"" );
                }
@@ -281,14 +275,9 @@ class LBFactoryMulti extends LBFactory {
                );
        }
 
-       /**
-        * @param string $cluster External storage cluster, or false for core
-        * @param DatabaseDomain|string|bool $domain Domain ID, or false for the current domain
-        * @return LoadBalancer
-        */
-       public function getExternalLB( $cluster, $domain = false ) {
+       public function getExternalLB( $cluster ) {
                if ( !isset( $this->extLBs[$cluster] ) ) {
-                       $this->extLBs[$cluster] = $this->newExternalLB( $cluster, $domain );
+                       $this->extLBs[$cluster] = $this->newExternalLB( $cluster );
                        $this->getChronologyProtector()->initLB( $this->extLBs[$cluster] );
                }
 
index 674bafd..1e69d8f 100644 (file)
@@ -91,13 +91,7 @@ class LBFactorySimple extends LBFactory {
                return $this->mainLB;
        }
 
-       /**
-        * @param string $cluster
-        * @param bool|string $domain
-        * @return LoadBalancer
-        * @throws InvalidArgumentException
-        */
-       public function newExternalLB( $cluster, $domain = false ) {
+       public function newExternalLB( $cluster ) {
                if ( !isset( $this->externalClusters[$cluster] ) ) {
                        throw new InvalidArgumentException( __METHOD__ . ": Unknown cluster \"$cluster\"." );
                }
@@ -105,14 +99,9 @@ class LBFactorySimple extends LBFactory {
                return $this->newLoadBalancer( $this->externalClusters[$cluster] );
        }
 
-       /**
-        * @param string $cluster
-        * @param bool|string $domain
-        * @return LoadBalancer
-        */
-       public function getExternalLB( $cluster, $domain = false ) {
+       public function getExternalLB( $cluster ) {
                if ( !isset( $this->extLBs[$cluster] ) ) {
-                       $this->extLBs[$cluster] = $this->newExternalLB( $cluster, $domain );
+                       $this->extLBs[$cluster] = $this->newExternalLB( $cluster );
                        $this->getChronologyProtector()->initLB( $this->extLBs[$cluster] );
                }
 
index a64117f..e116888 100644 (file)
@@ -55,36 +55,34 @@ class LBFactorySingle extends LBFactory {
        }
 
        /**
-        * @param bool|string $wiki
+        * @param bool|string $domain (unused)
         * @return LoadBalancerSingle
         */
-       public function newMainLB( $wiki = false ) {
+       public function newMainLB( $domain = false ) {
                return $this->lb;
        }
 
        /**
-        * @param bool|string $wiki
+        * @param bool|string $domain (unused)
         * @return LoadBalancerSingle
         */
-       public function getMainLB( $wiki = false ) {
+       public function getMainLB( $domain = false ) {
                return $this->lb;
        }
 
        /**
-        * @param string $cluster External storage cluster, or false for core
-        * @param bool|string $wiki Wiki ID, or false for the current wiki
+        * @param string $cluster External storage cluster name (unused)
         * @return LoadBalancerSingle
         */
-       public function newExternalLB( $cluster, $wiki = false ) {
+       public function newExternalLB( $cluster ) {
                return $this->lb;
        }
 
        /**
-        * @param string $cluster External storage cluster, or false for core
-        * @param bool|string $wiki Wiki ID, or false for the current wiki
+        * @param string $cluster External storage cluster name (unused)
         * @return LoadBalancerSingle
         */
-       public function getExternalLB( $cluster, $wiki = false ) {
+       public function getExternalLB( $cluster ) {
                return $this->lb;
        }
 
index 0dec95f..0a05202 100644 (file)
@@ -68,13 +68,6 @@ class LoadBalancerSingle extends LoadBalancer {
                return new static( [ 'connection' => $db ] + $params );
        }
 
-       /**
-        *
-        * @param string $server
-        * @param bool $dbNameOverride
-        *
-        * @return IDatabase
-        */
        protected function reallyOpenConnection( array $server, $dbNameOverride = false ) {
                return $this->db;
        }
index 53a474b..0a4f0ed 100644 (file)
@@ -326,9 +326,9 @@ class ObjectCache {
         * @throws UnexpectedValueException
         */
        public static function newWANCacheFromParams( array $params ) {
+               $erGroup = MediaWikiServices::getInstance()->getEventRelayerGroup();
                foreach ( $params['channels'] as $action => $channel ) {
-                       $params['relayers'][$action] = MediaWikiServices::getInstance()->getEventRelayerGroup()
-                               ->getRelayer( $channel );
+                       $params['relayers'][$action] = $erGroup->getRelayer( $channel );
                        $params['channels'][$action] = $channel;
                }
                $params['cache'] = self::newFromParams( $params['store'] );
index 01cce02..ef26db6 100644 (file)
@@ -487,40 +487,58 @@ class CoreParserFunctions {
                return $mwObject->matchStartToEnd( $value );
        }
 
-       public static function formatRaw( $num, $raw ) {
+       public static function formatRaw( $num, $raw, Language $language ) {
                if ( self::matchAgainstMagicword( 'rawsuffix', $raw ) ) {
                        return $num;
                } else {
-                       global $wgContLang;
-                       return $wgContLang->formatNum( $num );
+                       return $language->formatNum( $num );
                }
        }
+
        public static function numberofpages( $parser, $raw = null ) {
-               return self::formatRaw( SiteStats::pages(), $raw );
+               return self::formatRaw( SiteStats::pages(), $raw, $parser->getFunctionLang() );
        }
+
        public static function numberofusers( $parser, $raw = null ) {
-               return self::formatRaw( SiteStats::users(), $raw );
+               return self::formatRaw( SiteStats::users(), $raw, $parser->getFunctionLang() );
        }
        public static function numberofactiveusers( $parser, $raw = null ) {
-               return self::formatRaw( SiteStats::activeUsers(), $raw );
+               return self::formatRaw( SiteStats::activeUsers(), $raw, $parser->getFunctionLang() );
        }
+
        public static function numberofarticles( $parser, $raw = null ) {
-               return self::formatRaw( SiteStats::articles(), $raw );
+               return self::formatRaw( SiteStats::articles(), $raw, $parser->getFunctionLang() );
        }
+
        public static function numberoffiles( $parser, $raw = null ) {
-               return self::formatRaw( SiteStats::images(), $raw );
+               return self::formatRaw( SiteStats::images(), $raw, $parser->getFunctionLang() );
        }
+
        public static function numberofadmins( $parser, $raw = null ) {
-               return self::formatRaw( SiteStats::numberingroup( 'sysop' ), $raw );
+               return self::formatRaw(
+                       SiteStats::numberingroup( 'sysop' ),
+                       $raw,
+                       $parser->getFunctionLang()
+               );
        }
+
        public static function numberofedits( $parser, $raw = null ) {
-               return self::formatRaw( SiteStats::edits(), $raw );
+               return self::formatRaw( SiteStats::edits(), $raw, $parser->getFunctionLang() );
        }
+
        public static function pagesinnamespace( $parser, $namespace = 0, $raw = null ) {
-               return self::formatRaw( SiteStats::pagesInNs( intval( $namespace ) ), $raw );
+               return self::formatRaw(
+                       SiteStats::pagesInNs( intval( $namespace ) ),
+                       $raw,
+                       $parser->getFunctionLang()
+               );
        }
        public static function numberingroup( $parser, $name = '', $raw = null ) {
-               return self::formatRaw( SiteStats::numberingroup( strtolower( $name ) ), $raw );
+               return self::formatRaw(
+                       SiteStats::numberingroup( strtolower( $name ) ),
+                       $raw,
+                       $parser->getFunctionLang()
+               );
        }
 
        /**
@@ -727,7 +745,7 @@ class CoreParserFunctions {
 
                $title = Title::makeTitleSafe( NS_CATEGORY, $name );
                if ( !$title ) { # invalid title
-                       return self::formatRaw( 0, $raw );
+                       return self::formatRaw( 0, $raw, $parser->getFunctionLang() );
                }
                $wgContLang->findVariantLink( $name, $title, true );
 
@@ -753,7 +771,7 @@ class CoreParserFunctions {
                }
 
                $count = $cache[$name][$type];
-               return self::formatRaw( $count, $raw );
+               return self::formatRaw( $count, $raw, $parser->getFunctionLang() );
        }
 
        /**
@@ -769,7 +787,7 @@ class CoreParserFunctions {
                $title = Title::newFromText( $page );
 
                if ( !is_object( $title ) ) {
-                       return self::formatRaw( 0, $raw );
+                       return self::formatRaw( 0, $raw, $parser->getFunctionLang() );
                }
 
                // fetch revision from cache/database and return the value
@@ -779,7 +797,7 @@ class CoreParserFunctions {
                        // We've had bugs where rev_len was not being recorded for empty pages, see T135414
                        $length = 0;
                }
-               return self::formatRaw( $length, $raw );
+               return self::formatRaw( $length, $raw, $parser->getFunctionLang() );
        }
 
        /**
index 1cb5eef..208cf17 100644 (file)
@@ -104,7 +104,7 @@ abstract class Maintenance {
 
        /**
         * Used by getDB() / setDB()
-        * @var IDatabase
+        * @var Database
         */
        private $mDb = null;
 
@@ -726,6 +726,7 @@ abstract class Maintenance {
 
                if ( is_array( $wgProfiler ) && isset( $wgProfiler['class'] ) ) {
                        $class = $wgProfiler['class'];
+                       /** @var Profiler $profiler */
                        $profiler = new $class(
                                [ 'sampling' => 1, 'output' => [ $output ] ]
                                        + $wgProfiler
@@ -1182,6 +1183,7 @@ abstract class Maintenance {
                $this->beginTransaction( $dbw, __METHOD__ );
 
                # Get "active" text records from the revisions table
+               $cur = [];
                $this->output( 'Searching for active text records in revisions table...' );
                $res = $dbw->select( 'revision', 'rev_text_id', [], __METHOD__, [ 'DISTINCT' ] );
                foreach ( $res as $row ) {
index 068ee8c..aad85da 100644 (file)
@@ -6,7 +6,6 @@
                                "name": "Base",
                                "classes": [
                                        "mw",
-                                       "mw.Map",
                                        "mw.Message",
                                        "mw.loader",
                                        "mw.loader.store",
index b96e7eb..a672e29 100755 (executable)
@@ -145,6 +145,7 @@ class UpdateMediaWiki extends Maintenance {
 
                $this->output( "Going to run database updates for " . wfWikiID() . "\n" );
                if ( $db->getType() === 'sqlite' ) {
+                       /** @var Database|DatabaseSqlite $db */
                        $this->output( "Using SQLite file: '{$db->getDbFilePath()}'\n" );
                }
                $this->output( "Depending on the size of your database this may take a while!\n" );
index 6b23439..6280c95 100644 (file)
        }() );
 
        /**
-        * Create an object that can be read from or written to from methods that allow
+        * Create an object that can be read from or written to via methods that allow
         * interaction both with single and multiple properties at once.
         *
-        *     @example
-        *
-        *     var collection, query, results;
-        *
-        *     // Create your address book
-        *     collection = new mw.Map();
-        *
-        *     // This data could be coming from an external source (eg. API/AJAX)
-        *     collection.set( {
-        *         'John Doe': 'john@example.org',
-        *         'Jane Doe': 'jane@example.org',
-        *         'George van Halen': 'gvanhalen@example.org'
-        *     } );
-        *
-        *     wanted = ['John Doe', 'Jane Doe', 'Daniel Jackson'];
-        *
-        *     // You can detect missing keys first
-        *     if ( !collection.exists( wanted ) ) {
-        *         // One or more are missing (in this case: "Daniel Jackson")
-        *         mw.log( 'One or more names were not found in your address book' );
-        *     }
-        *
-        *     // Or just let it give you what it can. Optionally fill in from a default.
-        *     results = collection.get( wanted, 'nobody@example.com' );
-        *     mw.log( results['Jane Doe'] ); // "jane@example.org"
-        *     mw.log( results['Daniel Jackson'] ); // "nobody@example.com"
-        *
+        * @private
         * @class mw.Map
         *
         * @constructor
-        * @param {Object|boolean} [values] The value-baring object to be mapped. Defaults to an
-        *  empty object.
-        *  For backwards-compatibility with mw.config, this can also be `true` in which case values
-        *  are copied to the Window object as global variables (T72470). Values are copied in
-        *  one direction only. Changes to globals are not reflected in the map.
+        * @param {boolean} [global=false] Whether to synchronise =values to the global
+        *  window object (for backwards-compatibility with mw.config; T72470). Values are
+        *  copied in one direction only. Changes to globals do not reflect in the map.
         */
-       function Map( values ) {
-               if ( values === true ) {
-                       this.values = {};
+       function Map( global ) {
+               this.internalValues = {};
+               if ( global === true ) {
 
                        // Override #set to also set the global variable
                        this.set = function ( selection, value ) {
                                }
                                return false;
                        };
-
-                       return;
                }
 
-               this.values = values || {};
+               // Deprecated since MediaWiki 1.28
+               log.deprecate(
+                       this,
+                       'values',
+                       this.internalValues,
+                       'mw.Map#values is deprecated. Use mw.Map#get() instead.',
+                       'Map-values'
+               );
        }
 
        /**
         * @param {Mixed} value
         */
        function setGlobalMapValue( map, key, value ) {
-               map.values[ key ] = value;
-               mw.log.deprecate(
+               map.internalValues[ key ] = value;
+               log.deprecate(
                                window,
                                key,
                                value,
        }
 
        Map.prototype = {
+               constructor: Map,
+
                /**
                 * Get the value of one or more keys.
                 *
                 * @param {Mixed} [fallback=null] Value for keys that don't exist.
                 * @return {Mixed|Object| null} If selection was a string, returns the value,
                 *  If selection was an array, returns an object of key/values.
-                *  If no selection is passed, the 'values' container is returned. (Beware that,
+                *  If no selection is passed, the internal container is returned. (Beware that,
                 *  as is the default in JavaScript, the object is returned by reference.)
                 */
                get: function ( selection, fallback ) {
                        }
 
                        if ( typeof selection === 'string' ) {
-                               if ( !hasOwn.call( this.values, selection ) ) {
+                               if ( !hasOwn.call( this.internalValues, selection ) ) {
                                        return fallback;
                                }
-                               return this.values[ selection ];
+                               return this.internalValues[ selection ];
                        }
 
                        if ( selection === undefined ) {
-                               return this.values;
+                               return this.internalValues;
                        }
 
                        // Invalid selection key
 
                        if ( $.isPlainObject( selection ) ) {
                                for ( s in selection ) {
-                                       this.values[ s ] = selection[ s ];
+                                       this.internalValues[ s ] = selection[ s ];
                                }
                                return true;
                        }
                        if ( typeof selection === 'string' && arguments.length > 1 ) {
-                               this.values[ selection ] = value;
+                               this.internalValues[ selection ] = value;
                                return true;
                        }
                        return false;
 
                        if ( $.isArray( selection ) ) {
                                for ( s = 0; s < selection.length; s++ ) {
-                                       if ( typeof selection[ s ] !== 'string' || !hasOwn.call( this.values, selection[ s ] ) ) {
+                                       if ( typeof selection[ s ] !== 'string' || !hasOwn.call( this.internalValues, selection[ s ] ) ) {
                                                return false;
                                        }
                                }
                                return true;
                        }
-                       return typeof selection === 'string' && hasOwn.call( this.values, selection );
+                       return typeof selection === 'string' && hasOwn.call( this.internalValues, selection );
                }
        };
 
                 * @param {string} key Name of property to create in `obj`
                 * @param {Mixed} val The value this property should return when accessed
                 * @param {string} [msg] Optional text to include in the deprecation message
+                * @param {string} [logName=key] Optional custom name for the feature.
+                *  This is used instead of `key` in the message and `mw.deprecate` tracking.
                 */
                log.deprecate = !Object.defineProperty ? function ( obj, key, val ) {
                        obj[ key ] = val;
-               } : function ( obj, key, val, msg ) {
-                       msg = 'Use of "' + key + '" is deprecated.' + ( msg ? ( ' ' + msg ) : '' );
+               } : function ( obj, key, val, msg, logName ) {
+                       logName = logName || key;
+                       msg = 'Use of "' + logName + '" is deprecated.' + ( msg ? ( ' ' + msg ) : '' );
                        var logged = new StringSet();
                        function uniqueTrace() {
                                var trace = new Error().stack;
                                        enumerable: true,
                                        get: function () {
                                                if ( uniqueTrace() ) {
-                                                       mw.track( 'mw.deprecate', key );
+                                                       mw.track( 'mw.deprecate', logName );
                                                        mw.log.warn( msg );
                                                }
                                                return val;
                                        },
                                        set: function ( newVal ) {
                                                if ( uniqueTrace() ) {
-                                                       mw.track( 'mw.deprecate', key );
+                                                       mw.track( 'mw.deprecate', logName );
                                                        mw.log.warn( msg );
                                                }
                                                val = newVal;
                                }
                                return {
                                        name: key.slice( 0, index ),
-                                       version: key.slice( index )
+                                       version: key.slice( index + 1 )
                                };
                        }
 
index cb62fbf..a9d17ff 100644 (file)
         */
        mw.storage = {
 
-               localStorage: window.localStorage,
+               localStorage: ( function () {
+                       // Catch exceptions to avoid fatal in Chrome's "Block data storage" mode
+                       // which throws when accessing the localStorage property itself, as opposed
+                       // to the standard behaviour of throwing on getItem/setItem. (T148998)
+                       try {
+                               return window.localStorage;
+                       } catch ( e ) {}
+               }() ),
 
                /**
                 * Retrieve value from device storage.
index 52a1efb..63e7de8 100644 (file)
@@ -89,7 +89,7 @@
                 * @return {number} Current user's id, or 0 if user is anonymous
                 */
                getId: function () {
-                       return mw.config.get( 'wgUserId', 0 );
+                       return mw.config.get( 'wgUserId' ) || 0;
                },
 
                /**
index 79f37dc..b79c192 100644 (file)
         */
        QUnit.newMwEnvironment = ( function () {
                var warn, error, liveConfig, liveMessages,
+                       MwMap = mw.config.constructor, // internal use only
                        ajaxRequests = [];
 
-               liveConfig = mw.config.values;
-               liveMessages = mw.messages.values;
+               liveConfig = mw.config;
+               liveMessages = mw.messages;
 
                function suppressWarnings() {
                        warn = mw.log.warn;
                        // NOTE: It is important that we suppress warnings because extend() will also access
                        // deprecated properties and trigger deprecation warnings from mw.log#deprecate.
                        suppressWarnings();
-                       copy = $.extend( {}, liveConfig, custom );
+                       copy = $.extend( {}, liveConfig.get(), custom );
                        restoreWarnings();
 
                        return copy;
                }
 
                function freshMessagesCopy( custom ) {
-                       return $.extend( /*deep=*/true, {}, liveMessages, custom );
+                       return $.extend( /*deep=*/true, {}, liveMessages.get(), custom );
                }
 
                /**
                                setup: function () {
 
                                        // Greetings, mock environment!
-                                       mw.config.values = freshConfigCopy( localEnv.config );
-                                       mw.messages.values = freshMessagesCopy( localEnv.messages );
+                                       mw.config = new MwMap();
+                                       mw.config.set( freshConfigCopy( localEnv.config ) );
+                                       mw.messages = new MwMap();
+                                       mw.messages.set( freshMessagesCopy( localEnv.messages ) );
+                                       // Update reference to mw.messages
+                                       mw.jqueryMsg.setParserDefaults( {
+                                               messages: mw.messages
+                                       } );
+
                                        this.suppressWarnings = suppressWarnings;
                                        this.restoreWarnings = restoreWarnings;
 
                                        $( document ).off( 'ajaxSend', trackAjax );
 
                                        // Farewell, mock environment!
-                                       mw.config.values = liveConfig;
-                                       mw.messages.values = liveMessages;
+                                       mw.config = liveConfig;
+                                       mw.messages = liveMessages;
+                                       // Restore reference to mw.messages
+                                       mw.jqueryMsg.setParserDefaults( {
+                                               messages: liveMessages
+                                       } );
 
                                        // As a convenience feature, automatically restore warnings if they're
                                        // still suppressed by the end of the test.
index bfac513..7233a2e 100644 (file)
                return mw.loader.using( 'test.stale' )
                        .then( function () {
                                assert.strictEqual( count, 1 );
+                               // After implementing, registry contains version as implemented by the response.
+                               assert.strictEqual( mw.loader.getVersion( 'test.stale' ), 'v1', 'Override version' );
                                assert.strictEqual( mw.loader.getState( 'test.stale' ), 'ready' );
                                assert.ok( mw.loader.store.get( 'test.stale' ), 'In store' );
                        } )
index ab463a9..1518a80 100644 (file)
                );
        } );
 
-       QUnit.test( 'mw.Map', 35, function ( assert ) {
+       QUnit.test( 'mw.Map', function ( assert ) {
                var arry, conf, funky, globalConf, nummy, someValues;
 
                conf = new mw.Map();
+
                // Dummy variables
                funky = function () {};
                arry = [];
                        lorem: 'ipsum'
                }, 'Map.get returns multiple values correctly as an object' );
 
-               assert.deepEqual( conf, new mw.Map( conf.values ), 'new mw.Map maps over existing values-bearing object' );
-
                assert.deepEqual( conf.get( [ 'foo', 'notExist' ] ), {
                        foo: 'bar',
                        notExist: null
                }, 'Map.get return includes keys that were not found as null values' );
 
                // Interacting with globals and accessing the values object
+               this.suppressWarnings();
                assert.strictEqual( conf.get(), conf.values, 'Map.get returns the entire values object by reference (if called without arguments)' );
+               this.restoreWarnings();
 
                conf.set( 'globalMapChecker', 'Hi' );
 
                }
        } );
 
-       QUnit.test( 'mw.config', 1, function ( assert ) {
-               assert.ok( mw.config instanceof mw.Map, 'mw.config instance of mw.Map' );
-       } );
-
-       QUnit.test( 'mw.message & mw.messages', 100, function ( assert ) {
+       QUnit.test( 'mw.message & mw.messages', function ( assert ) {
                var goodbye, hello;
 
                // Convenience method for asserting the same result for multiple formats
                }
 
                assert.ok( mw.messages, 'messages defined' );
-               assert.ok( mw.messages instanceof mw.Map, 'mw.messages instance of mw.Map' );
                assert.ok( mw.messages.set( 'hello', 'Hello <b>awesome</b> world' ), 'mw.messages.set: Register' );
 
                hello = mw.message( 'hello' );
index 5122dcd..7f6efa0 100644 (file)
@@ -22,7 +22,7 @@
        QUnit.test( 'getters (anonymous)', function ( assert ) {
                // Forge an anonymous user
                mw.config.set( 'wgUserName', null );
-               delete mw.config.values.wgUserId;
+               mw.config.set( 'wgUserId', null );
 
                assert.strictEqual( mw.user.getName(), null, 'getName()' );
                assert.strictEqual( mw.user.isAnon(), true, 'isAnon()' );