Page MenuHomePhabricator

centralnotice breaks on IE6, causing error alerts on all pages (IE6 has no Array.prototype.indexOf)
Closed, ResolvedPublic

Description

http://upload.wikimedia.org/centralnotice/commons/en/centralnotice.js?283g
is broken on IE6 because it uses a call

DBsWithVector.indexOf()

where

var DBsWithVector = [ /* An array of strings */ ];

Array.prototype.indexOf doesn't exist on IE6 (and apparently also IE7, if I'm to believe web resources). The error message in IE6 says that "object does not support this method"--if only they had told me which object and which method, I wouldn't have had to search for some hours!

IE apparently does have an Array.indexOf "static" method, see
http://msdn.microsoft.com/en-us/library/bb383831.aspx
but that method is *not* on the prototype! I do not know whether this Array.indexOf static method is indeed available on IE6.

Note that the DBsWithVector thing is inside the string wgNotice!

Proposed fix:

There's two ways to fix this. Simple fix first: replace

DBsWithVector.indexOf( wgDBname )!= -1

by

(' ' + DBsWithVector.join (' ') + ' ').indexOf (' ' + wgDBname + ' ') != -1

IE6 does have Array.prototype.join, and it does have String.protype.indexOf, so this will work.

More proper fix: since DBsWithVector is used only for this test, change the array into an object:

var DBsWithVector =

{'enwiki':1, 'commonswiki':1, /* and so on, no comma after the last one! */ };

Then test using simply

DBsWithVector[wgDBname]

No need for indexOf at all.

Both proposed fixes should work on all browsers.

Marked "major" since this affects all skins and makes visiting Wikipedia for logged-in users with IE6 next to impossible. Luckily anons are unaffected by the bug, because the full test is

if ( wgUserName == null || DBsWithVector.indexOf( wgDBname )!= -1 ) ...


Version: unspecified
Severity: major
OS: other

Details

Reference
bz24083

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 11:01 PM
bzimport set Reference to bz24083.
bzimport added a subscriber: Unknown Object (MLST).

If i recall, Array.indexOf() is non-standard, and also not in opera.

Array.indexOf() is in JavaScript 1.6 ([[JavaScript#Versions]]).

ngautam wrote:

Fixed with a ridiculously long OR statement

Is this some Wikimedia stuff? Changing product and component.