Last modified: 2011-04-06 22:06:51 UTC

Wikimedia Bugzilla is closed!

Wikimedia has migrated from Bugzilla to Phabricator. Bug reports should be created and updated in Wikimedia Phabricator instead. Please create an account in Phabricator and add your Bugzilla email address to it.
Wikimedia Bugzilla is read-only. If you try to edit or create any bug report in Bugzilla you will be shown an intentional error message.
In order to access the Phabricator task corresponding to a Bugzilla report, just remove "static-" from its URL.
You could still run searches in Bugzilla or access your list of votes but bug reports will obviously not be up-to-date in Bugzilla.
Bug 19888 - allow wikibits.js to load without any required globals
allow wikibits.js to load without any required globals
Product: MediaWiki
Classification: Unclassified
General/Unknown (Other open bugs)
All All
: Normal enhancement with 1 vote (vote)
: ---
Assigned To: Nobody - You can work on this!
: patch
Depends on:
Blocks: javascript
  Show dependency treegraph
Reported: 2009-07-23 04:29 UTC by Splarka
Modified: 2011-04-06 22:06 UTC (History)
3 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---

Example patch of wikibits.js without global requirements (1.10 KB, patch)
2009-07-23 04:44 UTC, Splarka

Description Splarka 2009-07-23 04:29:54 UTC
Currently wikibits.js breaks (causes JS errors) anytime someone has no javascript globals (no call to Skin::makeGlobalVariablesScript). There are currently 3 globals fetched on the assumption that they are defined. It would be nice to have it not puke and die (and not define any mediawiki js functions at all, and often abort all further javascript on a page) when/if they're missing. 

This can happen when someone is using a custom skin that wasn't upgraded along with MediaWiki (either they recently upgraded, or grabbed a skin not meant for the version they have). Several times people have complained of javascript problems with their skin, due to their skin sucking. It wouldn't be so bad, except it breaks /all/ javascript for them, until they can either fix the skin themselves, or find the maintainer (if one exists) to fix it.

Also, wikibits.js might be a useful js to include with action=render for things like custom mini static dumps, and such.
Comment 1 Splarka 2009-07-23 04:44:28 UTC
Created attachment 6384 [details]
Example patch of wikibits.js without global requirements

Here is an example patch to make wikibits.js not fail without globals.

The stylepath change is a bit concerning, but a null stylepath here shouldn't really cause problems (or rather, any /more/ problems than that of the JS being totally broken).

A better solution would be to replace cases of 'stylepath' calls in sorttable with  a dummy variable assigned to the value of stylepth (or null if undefined), maybe.
Comment 2 Laurence 'GreenReaper' Parry 2009-09-03 03:59:16 UTC
Random note before I forget - the stylepath line should be either:
if (typeof stylepath == 'undefined') var stylepath = "";
or this shorter version (from Splarka):
var stylepath = stylepath || "";
Comment 3 Krinkle 2011-04-06 22:06:51 UTC
* wikbits.js is already deprecated, up to be quarantined in 1.19 into mw.legacy
* global wg* variables are also deprecated and moved to mw.config, currently still shadowed to the global space as well for backwards compatibility. All usage in core is or soon will be replaced.

One of the advantages to mw.config is that it wont cause any 'undefined' errors (takes care of that internally through the mw.Map() constructor)

Note You need to log in before you can comment on or make changes to this bug.