Last modified: 2014-08-29 02:01:15 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T57669, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 55669 - ResourceLoader: Script includes should check window.mw
ResourceLoader: Script includes should check window.mw
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
ResourceLoader (Other open bugs)
unspecified
All All
: Low major (vote)
: 1.24.0 release
Assigned To: Krinkle
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-10-13 05:43 UTC by John Mark Vandenberg
Modified: 2014-08-29 02:01 UTC (History)
5 users (show)

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


Attachments

Description John Mark Vandenberg 2013-10-13 05:43:33 UTC
The HTML includes lines like

<script src="https://bits.wikimedia.org/en.wikipedia.org/load.php?debug=false&lang=en&modules=user.groups&skin=vector&user=John+Vandenberg&version=20131012T104928Z&*"></script>

load.php returns JS which starts with

mw.loader.implement("user.groups",function(){...}

However object 'mw' doesnt exist when the browser fails the isCompatible test here:

https://git.wikimedia.org/blob/mediawiki%2Fcore.git/HEAD/resources%2Fstartup.js

load.php should return JS which starts with

if (window.mw) { mw.loader.implement("user.groups",function(){...} }
Comment 1 Krinkle 2013-10-14 06:36:43 UTC
Depending on whether we work on bug 30358 first, this bug becomes moot. Personally I'd prefer that.

The direct load.php requests embedded in the HTML, at least for scripts, are a hack because they bypass the client-side loader and with that the implementation logic and callback.

This is why we currently output additional script tags along side these (for modules=site, user, user.groups etc.) to set the state to "loading" and/or "ready".

I'd much rather fix bug 30358, and keep the model that if you make a request to load.php, unless you set raw=1, you are expected to handle mw.loader.implement. If you can't (e.g. because the browser isn't compatible and didn't get the mediawiki.loader payload) that request shouldn't be fired in the first place.

- It's a wasted request.
- Requires hardcoded script tags.
- Requires the mw.loader.state "loading" hacks in the html.

Of course, if bug 30358 takes too much to fix on the short term, we could work around it by prefixing load.php responses with `window.mw&&`, but I'd rather not as it masks errors and makes it harder to detect that the 3 points above are required by the client.
Comment 2 Krinkle 2013-10-14 06:39:33 UTC
Lowering priority since these exceptions happen in a global and isolated execution scope (doesn't affect other scripts, though even if it didn't, there most likely aren't any other scripts), plus, they shouldn't be visible to non-developers anyway (except for IE which in older versions does its "This web page has an error" thing by default, though configurable).
Comment 3 Umherirrender 2013-10-14 19:11:16 UTC
A RessourceLoader::makeLoaderConditionalScript function exists for this and it is used in some places.
Comment 4 Krinkle 2014-08-29 02:01:06 UTC
Fixed.

> resourceloader: Wrap only=script responses in "if(window.mw)"
>
> Change-Id: Icf6ede09b51ce212aa70ff6be4b341762ec75b4d

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


Navigation
Links