Last modified: 2014-02-12 23:52:54 UTC
Changesets https://gerrit.wikimedia.org/r/#/c/43979/ and https://gerrit.wikimedia.org/r/#/c/44442/ introduce changes that make mobile ResourceLoader modules for SpecialPages get dynamically defined. This is neat, however the current implementation in master (https://gerrit.wikimedia.org/r/#/c/44442/) makes it so that the modules get defined on EVERY request, including API requests, which adds unnecessary overhead. We initially attempted to have the processing happen ONLY inside of the invocation of the ResourceLoaderRegisterModules hook, which works in MobileFrontend alpha/beta, but not in production. There are a couple of reasons for this: 1) The ResourceLoaderRegisterModules hook runs AFTER SkinMobile::attachAdditionalPageResources() attaches resources (when RL is not fully in use, eg in production). You can try to get around that by forcing the hook to run by calling OutputPage::getResourceLoader() in SkinMobile::attachAdditionalPageResources(), but that bumps into another problem: 2) using $resourceLoader->registerModule() in an invocation of the ResourceLoaderRegisterModules hook appears to not work properly for modules that need to be loaded at the bottom of the page. I'll be filing a separate bug for that. We should get this fixed sooner rather than later. A few options I can think of: * Fix #2 above * Add a hook in SkinMobile to dynamically load last-minute modules into $wgResourceModules (this is ugly, but would go away once we resolve https://bugzilla.wikimedia.org/show_bug.cgi?id=41340)
Actually it sounds like the issue I mentioned in #2 above is NOTE a ResourceLoader issue, but rather a problem in MobileFrontend: https://bugzilla.wikimedia.org/show_bug.cgi?id=44072
Is this fixed now?
No, the SpecialPage related modules are still getting prepared on every request. They should get handled in MobileFrontendHooks::onResourceLoaderRegisterModules(). Since bug 44072 is fixed now, this should be totally doable.
I've seen this code is proving to cause troubles for people understanding our code, so I put my hand up and say this was a bad idea. Instead I will manually define the modules. Patch on it's way.
I don't know any context behind this bug, but I just want to make a quick point. Remember that load.php/startup module needs it, since they are loaded not from within the page. Module definitions mustn't rely on page context. The startup module needs a complete overview (which is by design).
https://gerrit.wikimedia.org/r/52254