Merge "Implement OOUI version of tag filter in ChangeTags"
[lhc/web/wiklou.git] / resources / src / mediawiki / mediawiki.js
index 0c24720..c0b1642 100644 (file)
 
                        /**
                         * Write a message the console's warning channel.
-                        * Also logs a stacktrace for easier debugging.
                         * Actions not supported by the browser console are silently ignored.
                         *
                         * @param {string...} msg Messages to output to console
                                var console = window.console;
                                if ( console && console.warn && console.warn.apply ) {
                                        console.warn.apply( console, arguments );
-                                       if ( console.trace ) {
-                                               console.trace();
-                                       }
                                }
                        };
 
                        function addEmbeddedCSS( cssText, callback ) {
                                var $style, styleEl;
 
+                               function fireCallbacks() {
+                                       var oldCallbacks = cssCallbacks;
+                                       // Reset cssCallbacks variable so it's not polluted by any calls to
+                                       // addEmbeddedCSS() from one of the callbacks (T105973)
+                                       cssCallbacks = $.Callbacks();
+                                       oldCallbacks.fire().empty();
+                               }
+
                                if ( callback ) {
                                        cssCallbacks.add( callback );
                                }
                                                } else {
                                                        styleEl.appendChild( document.createTextNode( cssText ) );
                                                }
-                                               cssCallbacks.fire().empty();
+                                               fireCallbacks();
                                                return;
                                        }
                                }
 
                                $( newStyleTag( cssText, getMarker() ) ).data( 'ResourceLoaderDynamicStyleTag', true );
 
-                               cssCallbacks.fire().empty();
+                               fireCallbacks();
                        }
 
                        /**
 
                                $.each( dependencies, function ( idx, module ) {
                                        var state = mw.loader.getState( module );
+                                       // Only queue modules that are still in the initial 'registered' state
+                                       // (not ones already loading, ready or error).
                                        if ( state === 'registered' && $.inArray( module, queue ) === -1 ) {
+                                               // Private modules must be embedded in the page. Don't bother queuing
+                                               // these as the server will deny them anyway (T101806).
+                                               if ( registry[module].group === 'private' ) {
+                                                       registry[module].state = 'error';
+                                                       handlePending( module );
+                                                       return;
+                                               }
                                                queue.push( module );
                                                if ( async ) {
                                                        registry[module].async = true;
                                        // Whether the store is in use on this page.
                                        enabled: null,
 
+                                       // Modules whose string representation exceeds 100 kB are ineligible
+                                       // for storage due to bug T66721.
+                                       MODULE_SIZE_MAX: 100000,
+
                                        // The contents of the store, mapping '[module name]@[version]' keys
                                        // to module implementations.
                                        items: {},
                                         * @param {Object} descriptor The module's descriptor as set in the registry
                                         */
                                        set: function ( module, descriptor ) {
-                                               var args, key;
+                                               var args, key, src;
 
                                                if ( !mw.loader.store.enabled ) {
                                                        return false;
                                                        return;
                                                }
 
-                                               mw.loader.store.items[key] = 'mw.loader.implement(' + args.join( ',' ) + ');';
+                                               src = 'mw.loader.implement(' + args.join( ',' ) + ');';
+                                               if ( src.length > mw.loader.store.MODULE_SIZE_MAX ) {
+                                                       return false;
+                                               }
+                                               mw.loader.store.items[key] = src;
                                                mw.loader.store.update();
                                        },
 
                                                        if ( mw.loader.store.getModuleKey( module ) !== key ) {
                                                                mw.loader.store.stats.expired++;
                                                                delete mw.loader.store.items[key];
+                                                       } else if ( mw.loader.store.items[key].length > mw.loader.store.MODULE_SIZE_MAX ) {
+                                                               // This value predates the enforcement of a size limit on cached modules.
+                                                               delete mw.loader.store.items[key];
                                                        }
                                                }
                                        },