From 818841a0799c985c8f1bcf7a9e1e9efbc4625d8d Mon Sep 17 00:00:00 2001 From: Florian Date: Thu, 7 Jan 2016 17:46:16 +0100 Subject: [PATCH] Fix Race-Condition in mediawiki.page.ready OOJs-UI infusion It's possible, that the "catlinks" $nodes variable is re-assigned, before mw.loader.using finished loading the mediawiki.widgets modules (which will trigger the execution of the passed function). The function inside the mw.loader.using call uses the $nodes variable and expects a set of infusable OOUI elements, but (depending on the loading time of the modules) it's already re-assigned with the .catlinks element. Fix this by renaming the variable $nodes to $oouiNodes to break this race condition. It's possible to rename the variable used for catlinks, but $nodes is used in other places of the code, too, so I think this is the nicer solution. Bug: T123074 Change-Id: Ie18b576a16c33645ab04e2957b23169bc2e17202 --- resources/src/mediawiki/page/ready.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/resources/src/mediawiki/page/ready.js b/resources/src/mediawiki/page/ready.js index 4385a2e903..9b3458bdfc 100644 --- a/resources/src/mediawiki/page/ready.js +++ b/resources/src/mediawiki/page/ready.js @@ -36,7 +36,7 @@ // Things outside the wikipage content $( function () { - var $nodes; + var $nodes, $oouiNodes; if ( !supportsPlaceholder ) { // Exclude content to avoid hitting it twice for the (first) wikipage content @@ -60,11 +60,11 @@ $nodes.updateTooltipAccessKeys(); // Infuse OOUI widgets, if any are present - $nodes = $( '[data-ooui]' ); - if ( $nodes.length ) { + $oouiNodes = $( '[data-ooui]' ); + if ( $oouiNodes.length ) { // FIXME: We should only load the widgets that are being infused mw.loader.using( [ 'mediawiki.widgets', 'mediawiki.widgets.UserInputWidget' ] ).done( function () { - $nodes.each( function () { + $oouiNodes.each( function () { OO.ui.infuse( this ); } ); } ); -- 2.20.1