Page MenuHomePhabricator

Special:BannerController breaks all JS on live site
Closed, InvalidPublic

Description

Seen on mw.org in Opera 11:

Uncaught exception: ReferenceError: Undefined variable: jQuery

Error thrown at line 28, column 0 in http://www.mediawiki.org/w/index.php?title=Special:BannerController&cache=/cn.js&283-17:

( function( $ ) {

Screws up all JS on page.


Version: unspecified
Severity: critical

Details

Reference
bz26381

Event Timeline

bzimport raised the priority of this task from to High.Nov 21 2014, 11:12 PM
bzimport set Reference to bz26381.

Works for me in Firefox, and the inclusion order in <head> looks correct. Opera is known to have issues with loading order, though.

Works for me as well. I suppose I could have CentralNotice make sure that jQuery is defined before it does anything. Any other suggestions?

Tested mediawiki.org and en.wikipedia.org in Opera 11 with CentralNotice banners running, but was not able to reproduce the bug. Max, can you describe the steps to reproduce this bug? Are you still seeing it?

Works for me from home. Probably, something weird with transparent proxy at work. Will investigate this after holidays.

Hey Max, were you able to investigate this at work?

JavaScript crash in FF 3.6.4. Observed while visiting the Commons in Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.4) Gecko/20100611 Firefox/3.6.4, may possibly also occur in other browsers.

The crash occurs during $j(document).ready() and prevents later document-ready handlers from running at all.

FF error console reports:

uncaught exception: [Exception... "Component returned failure code: 0x805e000a [nsIXMLHttpRequest.open]" nsresult: "0x805e000a (<unknown>)" location: "JS frame :: http://bits.wikimedia.org/skins-1.5/common/jquery.min.js?283-19 :: anonymous :: line 383" data: no]

This appears to be caused by the call on lines 54-58 in http://commons.wikimedia.org/wiki/Special:BannerController

var request = $.ajax( {
url: bannerListURL,
dataType: 'json',
success: $.centralNotice.fn.chooseBanner
} );

The bannerListURL at the time of the call is

http://commons.wikimedia.org/w/index.php?title=Special:BannerListLoader&cache=/cn.js&language=en&project=commons&country=

and returns

which is not a JSON object but an empty array. Maybe that's got something to do with this. Can't verify myself since I cannot step though minified jquery code; I did get to this $.ajax() call with single-stepping, though. $.centralNotice.fn.chooseBanner is never called; the exception is therefore raised earlier inside the $.ajax() call.

The error appears not to depend on the skin, at least it occurs in both monobook and in vector.

Created attachment 7984
Dragonfly debug info

Here's what I've discovered. Everything seems to be loaded, but jQuery is a roast. Errors look different at different times (at the moment of reporting the BannerController error was first in the list, so I decided that it is to be blamed). Sometimes, there are no errors and JS works, but most of time it's completely screwed up.

Attached:

@Lupo: '[]' is the correct json encoding for an empty array. That shouldn't cause any problems. In fact, '[]' is the value that is normally expected to be returned (when we aren't running banners).

Never mind, I'm an idiot. It was an Opera extension screwing up things.