Last modified: 2013-09-04 11:49:34 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 T32914, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 30914 - Embeddable ResourceLoader modules (user.options, user.tokens) should be loaded in <head> for proper dependency resolution
Embeddable ResourceLoader modules (user.options, user.tokens) should be loade...
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
ResourceLoader (Other open bugs)
1.17.x
All All
: Normal normal (vote)
: 1.19.0 release
Assigned To: Krinkle
:
Depends on:
Blocks: gadgets-2.0
  Show dependency treegraph
 
Reported: 2011-09-15 15:10 UTC by Roan Kattouw
Modified: 2013-09-04 11:49 UTC (History)
3 users (show)

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


Attachments

Description Roan Kattouw 2011-09-15 15:10:46 UTC
user.tokens and user.options are inlined all the way at the bottom of the page. This is causing bugs when modules depend on user.tokens (which none do yet, which is kind of bad when you think about it), because the following happens:

* loader resolves dependencies for foo
* loader loads foo|user.tokens
* mw.implement( 'user.tokens', ... ) is called
* foo is loaded normally and can use mw.user.tokens
* the inlined <script> tag call mw.implement( 'user.tokens', ... ) again, resulting in an exception

There is no good reason for user.tokens and user.options to be inlined at the /bottom/. We should inline them at the top, before the top-load queue.
Comment 1 Krinkle 2011-09-17 01:49:52 UTC
yeah, that goes for any embedded module for that matter. Anything embedded in the html cannot be removed from the 'load queue' since it's stuck in the HTML, so it needs to be in the top of the document before the first loader.load.

One thing to keep in mind though is that user.tokens depends on 'mediawiki.user' (obviously).

We just need to verify that "mw.loader.implement('user.tokens')" doesn't do anything (i.e. it should not trigger an ajax request to get 'mediawiki.user', because 1) nobody asked for 'user.tokens', so no need to resolve dependencies, 2) because 'mediawiki.user' is expected to be in the next loader.load call
Comment 2 Roan Kattouw 2011-09-20 10:24:23 UTC
(In reply to comment #1)
> yeah, that goes for any embedded module for that matter. Anything embedded in
> the html cannot be removed from the 'load queue' since it's stuck in the HTML,
> so it needs to be in the top of the document before the first loader.load.
> 
Yup, that's right.

> One thing to keep in mind though is that user.tokens depends on
> 'mediawiki.user' (obviously).
> 
That's not a problem. If we load it inside an implement() call, normal dependency resolution will take care of this.

> We just need to verify that "mw.loader.implement('user.tokens')" doesn't do
> anything (i.e. it should not trigger an ajax request to get 'mediawiki.user',
> because 1) nobody asked for 'user.tokens', so no need to resolve dependencies,
> 2) because 'mediawiki.user' is expected to be in the next loader.load call
I'm not at all worried about that, that's fundamentally not what implement() does. implement() means "look here's the code for this new module, you may or may not be able to run it now depending on the status of its dependencies".
Comment 3 Krinkle 2011-12-28 21:47:54 UTC
Okay, so no issues left to resolve.

Looks like first usage has come along. mw.Api module is using this as of r107350.

I'll go ahead and move those to the head and see what happens.
Comment 4 Krinkle 2011-12-28 22:20:47 UTC
Fixed in r107534

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


Navigation
Links