Page MenuHomePhabricator

ResourceLoader: Implied global function not a global function outside debug mode
Closed, InvalidPublic

Description

From https://bugzilla.mozilla.org/show_bug.cgi?id=854395

To test a minimization problem, I created a page in the sandbox. This resulted in a JS error when clicking "show" (preventing the toggle from working). Adding &debug=true to the URL -- to stop JS minimization -- allows the toggle to work without an error.

https://www.mediawiki.org/w/index.php?title=Project:Sandbox&oldid=664164

https://www.mediawiki.org/w/index.php?title=Project:Sandbox&oldid=664164&debug=true


Version: unspecified
Severity: normal

Details

Reference
bz46582

Event Timeline

bzimport raised the priority of this task from to Needs Triage.Nov 22 2014, 1:20 AM
bzimport set Reference to bz46582.
bzimport added a subscriber: Unknown Object (MLST).

This has nothing to do with minification.

Class "collapsible" is something that is handled by a community maintained gadget. A gadget that is several years old having many (mostly unmaintained) copies on many wikis.

It has been failing on various wikis where the old version is still used that assumes the legacy loading method where everything is a global variable.

The reason it works in debug mode is because in debug mode the scripts are loaded via <script> in the global scope.

The solution is to either:

  • Upgrade your copy of the community-maintained "collapsible" gadget on your wiki.
  • Use mw-collapsible instead (which is handled by jquery.makeCollapsible).

The old installation of wiki.mozilla.org did not have the Gadgets extension installed, so it didn't use the old gadget. The new Gadget would work as would mw-collapsible. Ideas?

(In reply to comment #4)

The old installation of wiki.mozilla.org did not have the Gadgets extension
installed, so it didn't use the old gadget. The new Gadget would work as
would mw-collapsible. Ideas?

If they don't have the Gadgets extension installed they likely have it in their Common.js, so upgrade it there instead.

(In reply to comment #4)

The old installation of wiki.mozilla.org did not have the Gadgets extension
installed, so it didn't use the old gadget. The new Gadget would work as
would mw-collapsible. Ideas?

If they don't have the Gadgets extension installed they likely have it in their
Common.js, so upgrade it there instead.

(Quoting comment #1)

The solution is to either:

  • Upgrade your copy of the gadget on your wiki.
  • Use mw-collapsible instead (which is handled by jquery.makeCollapsible).

In their case, since they have a lot of existing pages with "collapsible", is probably best to upgrade it and from now no slowly migrate to using mw-collapsible instead.

Alternatively if they don't mind not having collapsible tables on old pages (it's only a minor enhancement) they could decide to simply remove the old broken code from their Common.js and just use core's mw-collapsible from now on.