Page MenuHomePhabricator

mw.loader.impl is not available on enwiki
Closed, ResolvedPublicBUG REPORT

Description

tl;dr: Uncaught TypeError: mw.loader.impl is not a function on enwiki

The script provided by https://meta.wikimedia.org/w/load.php returns a script that starts with mw.loader.impl. This function is only defined on wikimedia.org and not en.wikipedia.org.

Steps to replicate the issue (include links if applicable):

  • Load an English Wikipedia page with a user script hosted globally on meta.wikimedia.

What happens?:
Script does not load.

What should have happened instead?:
Script loads.

Other information (browser name/version, screenshots, etc.):
N/A

Event Timeline

Sorry, I thought we wouldn't need that cherry pick because the rest of the branch wasn't merged yet -- didn't look closely enough. I will deploy it now.

Although it looks like everything is on wmf.22 now, so too late. It should be fixed already.

tstarling claimed this task.

I can't reproduce it anyway, because I don't know how you load a user script from meta in a way that would trigger this error. I tried checking Northern Moonlight's user scripts, but there was nothing helpful there. Most user common.js pages just use importScript() or importScriptURI(), neither of which use mw.loader.impl() as far as I can tell.

Can confirm, global user scripts now load properly on Wikipedia.

I can't reproduce it anyway, because I don't know how you load a user script from meta in a way that would trigger this error.

The error would happen for scripts imported on a user's global.js on Meta Wiki using mw.loader.load (see mine for example).

This is resolved, but for the record, here’s an example of the script that was used on enwiki:

https://meta.wikimedia.org/w/load.php?lang=fr&modules=ext.globalCssJs.user&skin=vector&user=SuperHamster&version=hoi2y

It wrapped the userscript in a mw.loader.impl() call.

I can't reproduce it anyway, because I don't know how you load a user script from meta in a way that would trigger this error. I tried checking Northern Moonlight's user scripts, but there was nothing helpful there. Most user common.js pages just use importScript() or importScriptURI(), […]

The "common.js" page itself is defined and loaded by MW core via ResourceLoader ("user" module). From there, people use those functions to load raw scripts from anywhere indeed.

The "global.js" page on Meta-Wiki is defined and loaded as ResourceLoader module by the GlobalCssJs extension (ext.globalCssJs.user). This uses an extra "source" ($wgResourceLoaderSources, which is why mw.loader splits requests by source and group). This is not unlike how we also have mulitple file backends to load images from Commons. This mechanism was originally developed for use by the Gadgets extension (which still doesn't use it today) and CentralNotice (which transitioned to a local module that queries metawiki DB directly).

I'm experiencing this bug on an external wiki, where we're trying to import the Navigation Popups gadget. Is there something we can/need to do over there to fix this? (Currently on mw 1.39.0)
https://noita.wiki.gg/wiki/MediaWiki:Gadget-NavigationPopups.js

image.png (610×1 px, 221 KB)

I'm experiencing this bug on an external wiki, where we're trying to import the Navigation Popups gadget. Is there something we can/need to do over there to fix this? (Currently on mw 1.39.0)

You can cherry pick 90681f2d884d1a9fca0945acd733e24c143e1b19