Page MenuHomePhabricator

Remove obsolete aliases from closures
Open, Needs TriagePublic

Description

Apply changes from https://gerrit.wikimedia.org/r/#/c/mediawiki/core/+/456068/ to other extensions

@Krinkle wrote:

jQuery

ResourceLoader wraps and executes all modules in the system via a closure that explicitly binds '$', 'jQuery'. This means there is no point in aliasing jQuery to $ in every single file. ResourceLoader already does this.
This is a very very old habit that was introduced in 2009 when we didn't have ResourceLoader and were concerned with wikis loading their own copy of jQuery that could redefine the global 'jQuery' and '$' variables. We simply hoped that "our module" initialised before "that module" cache the reference we got in the file closure.
Then in 2010, when building ResourceLoader, we found this didn't always work. And we also sometimes forgot to add the closure. Which is why in 2010 (before ResourceLoader went to prod, in 2011) we fixed the above issue in ResourceLoader itself by "magically" providing a private binding to '$' and 'jQuery' in every mw.loader.implement() closure. (r79246, bd93eeb85).
So, these in-file closure references are redundant. And have been since 2010.

jQuery, again.

While redundant, they remained in most files. Harmless, right?
However, that same problem of duplicate jQuery copys on a page came up again in 2013. Why did our magic binding not work?
It was *because* the file also did its own binding:

  1. ResourceLoader stores reference to proper jQuery.
  2. ResourceLoader provides private reference to it as '$'.
  3. .. time passes ..
  4. Module executes, and is given the proper jQuery via the private '$' reference. The module file ignores this because it instead looks up current jQuery, and caches that. So, we expande the magic binding to also bind the name 'jQuery'. (2013-2014; 5742c1f38527).

mediaWiki

We export the binding as 'mw' and 'mediaWiki'. We internally mostly use 'mw' (in HTML, and documentation, and the canonical name in the JSDuck index). But, rather than using the shorter name, we use the longer name and alias it in every single file.
There was never a concern about this global being redefined as far as I know. However, if that happens one day, we should.. provide a magic binding for it.

Details

Related Gerrit Patches:
mediawiki/extensions/Popups : masterRemove obsolete `mediaWiki` and `jQuery` aliases
mediawiki/extensions/CentralAuth : masterbuild: Update eslint config and apply newer conventions
mediawiki/extensions/ShortUrl : masterRemove obsolete aliases from closures in JS code
mediawiki/extensions/SecurePoll : masterRemove obsolete aliases from closures in JS code
mediawiki/extensions/ReadingLists : masterbuild: Remove unused jquery/mw from eslint config
mediawiki/extensions/ApiFeatureUsage : masterbuild: Structure update
mediawiki/extensions/VipsScaler : masterbuild: Structure updates
mediawiki/extensions/examples : masterUpdate Example extension with various best practices
mediawiki/extensions/examples : masterUpdate Example extension with various best practices
data-values/value-view : masterRemove obsolete aliases from closures
mediawiki/extensions/QuickSurveys : masterbuild: Update eslint rules and remove redundant aliases
mediawiki/extensions/MobileFrontend : masterRemove obsolete aliases from closures
mediawiki/extensions/WikibaseLexeme : masterRemove obsolete aliases from closures
mediawiki/extensions/TocTree : masterRemove obsolete aliases from closures
mediawiki/extensions/CentralNotice : masterRemove obsolete aliases from closures
mediawiki/extensions/ReplaceText : masterRemove obsolete aliases from closures
mediawiki/extensions/CategoryTree : masterRemove obsolete aliases from closures
mediawiki/extensions/GuidedTour : masterRemove obsolete aliases from closures
mediawiki/extensions/WikimediaMessages : masterRemove obsolete aliases from closures, and fix line lengths
mediawiki/extensions/BetaFeatures : masterRemove obsolete aliases from closures
mediawiki/extensions/AbuseFilter : masterRemove obsolete aliases from closures
mediawiki/skins/MinervaNeue : masterRemove obsolete aliases from closures
mediawiki/extensions/RevisionSlider : masterRemove obsolete aliases from closures
mediawiki/extensions/wikihiero : masterRemove obsolete aliases from closures
mediawiki/extensions/TemplateWizard : masterRemove obsolete aliases from closures
mediawiki/skins/Timeless : masterRemove obsolete aliases from closures
mediawiki/skins/Vector : masterRemove obsolete aliases from closures
mediawiki/extensions/WikibaseMediaInfo : masterRemove obsolete aliases from closures
mediawiki/extensions/CharInsert : masterRemove obsolete aliases from closures
mediawiki/extensions/TwoColConflict : masterRemove obsolete aliases from closures
mediawiki/extensions/UploadWizard : masterRemove obsolete aliases from closures
mediawiki/extensions/MassMessage : masterRemove obsolete aliases from closures
mediawiki/extensions/PageTriage : masterRemove obsolete aliases from closures
mediawiki/extensions/ORES : masterRemove obsolete aliases from closures
mediawiki/extensions/WikiEditor : masterRemove obsolete aliases from closures
mediawiki/extensions/Linter : masterRemove obsolete aliases from closures
mediawiki/extensions/Thanks : masterRemove obsolete aliases from closures
mediawiki/extensions/GlobalPreferences : masterRemove obsolete aliases from closures
mediawiki/extensions/Graph : masterRemove obsolete aliases from closures
mediawiki/extensions/Flow : masterRemove obsolete aliases from closures
mediawiki/extensions/MultimediaViewer : masterRemove obsolete aliases from closures
mediawiki/extensions/TimedMediaHandler : masterRemove obsolete aliases from closures
mediawiki/extensions/Echo : masterRemove obsolete aliases from closures
mediawiki/extensions/FlaggedRevs : masterRemove obsolete aliases from closures
mediawiki/extensions/CodeEditor : masterRemove obsolete aliases from closures
mediawiki/extensions/ConfirmEdit : masterRemove obsolete aliases from closures
mediawiki/extensions/ExtensionDistributor : masterRemove obsolete aliases from closures
mediawiki/extensions/CodeMirror : masterRemove obsolete aliases from closures
mediawiki/skins/apex : masterRemove obsolete aliases from closures
mediawiki/extensions/Cite : masterRemove obsolete aliases from closures
mediawiki/extensions/LiquidThreads : masterRemove obsolete aliases from closures
mediawiki/extensions/Translate : masterRemove obsolete aliases from closures
mediawiki/extensions/ContentTranslation : masterRemove obsolete aliases from closures
mediawiki/extensions/Wikibase : masterRemove obsolete aliases from closures
mediawiki/extensions/Math : masterRemove obsolete aliases from closures
mediawiki/extensions/Kartographer : masterRemove obsolete aliases from closures
mediawiki/extensions/AdvancedSearch : masterRemove obsolete aliases from closures
mediawiki/extensions/BoilerPlate : masterRemove obsolete aliases from closures
mediawiki/extensions/3D : masterRemove obsolete aliases from closures

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes

Change 472975 merged by jenkins-bot:
[mediawiki/skins/apex@master] Remove obsolete aliases from closures

https://gerrit.wikimedia.org/r/472975

Change 472980 merged by jenkins-bot:
[mediawiki/extensions/CodeMirror@master] Remove obsolete aliases from closures

https://gerrit.wikimedia.org/r/472980

Change 472981 merged by jenkins-bot:
[mediawiki/extensions/ConfirmEdit@master] Remove obsolete aliases from closures

https://gerrit.wikimedia.org/r/472981

Change 472990 merged by jenkins-bot:
[mediawiki/extensions/ExtensionDistributor@master] Remove obsolete aliases from closures

https://gerrit.wikimedia.org/r/472990

Change 472989 merged by jenkins-bot:
[mediawiki/extensions/Echo@master] Remove obsolete aliases from closures

https://gerrit.wikimedia.org/r/472989

Change 472978 merged by jenkins-bot:
[mediawiki/extensions/CodeEditor@master] Remove obsolete aliases from closures

https://gerrit.wikimedia.org/r/472978

Change 472992 merged by jenkins-bot:
[mediawiki/extensions/FlaggedRevs@master] Remove obsolete aliases from closures

https://gerrit.wikimedia.org/r/472992

Change 472998 merged by jenkins-bot:
[mediawiki/extensions/Flow@master] Remove obsolete aliases from closures

https://gerrit.wikimedia.org/r/472998

Change 473002 merged by jenkins-bot:
[mediawiki/extensions/GlobalPreferences@master] Remove obsolete aliases from closures

https://gerrit.wikimedia.org/r/473002

Change 473010 merged by jenkins-bot:
[mediawiki/extensions/Graph@master] Remove obsolete aliases from closures

https://gerrit.wikimedia.org/r/473010

Change 473017 merged by jenkins-bot:
[mediawiki/extensions/Linter@master] Remove obsolete aliases from closures

https://gerrit.wikimedia.org/r/473017

Change 473039 merged by jenkins-bot:
[mediawiki/extensions/MultimediaViewer@master] Remove obsolete aliases from closures

https://gerrit.wikimedia.org/r/473039

Change 473042 merged by jenkins-bot:
[mediawiki/extensions/TimedMediaHandler@master] Remove obsolete aliases from closures

https://gerrit.wikimedia.org/r/473042

Change 473046 merged by jenkins-bot:
[mediawiki/extensions/ORES@master] Remove obsolete aliases from closures

https://gerrit.wikimedia.org/r/473046

Change 473060 merged by jenkins-bot:
[mediawiki/extensions/PageTriage@master] Remove obsolete aliases from closures

https://gerrit.wikimedia.org/r/473060

Change 473033 merged by jenkins-bot:
[mediawiki/extensions/MassMessage@master] Remove obsolete aliases from closures

https://gerrit.wikimedia.org/r/473033

Change 473068 merged by jenkins-bot:
[mediawiki/extensions/Thanks@master] Remove obsolete aliases from closures

https://gerrit.wikimedia.org/r/473068

Change 473076 merged by jenkins-bot:
[mediawiki/extensions/UploadWizard@master] Remove obsolete aliases from closures

https://gerrit.wikimedia.org/r/473076

Change 473139 merged by jenkins-bot:
[mediawiki/extensions/WikiEditor@master] Remove obsolete aliases from closures

https://gerrit.wikimedia.org/r/473139

Change 473073 merged by jenkins-bot:
[mediawiki/extensions/TwoColConflict@master] Remove obsolete aliases from closures

https://gerrit.wikimedia.org/r/473073

Change 472977 merged by jenkins-bot:
[mediawiki/extensions/CharInsert@master] Remove obsolete aliases from closures

https://gerrit.wikimedia.org/r/472977

Change 473615 had a related patch set uploaded (by Jforrester; owner: Jforrester):
[mediawiki/extensions/WikimediaMessages@master] Remove obsolete aliases from closures, and fix line lengths

https://gerrit.wikimedia.org/r/473615

Change 473618 had a related patch set uploaded (by Jforrester; owner: Jforrester):
[mediawiki/extensions/WikibaseMediaInfo@master] Remove obsolete aliases from closures

https://gerrit.wikimedia.org/r/473618

Change 473618 merged by jenkins-bot:
[mediawiki/extensions/WikibaseMediaInfo@master] Remove obsolete aliases from closures

https://gerrit.wikimedia.org/r/473618

Change 474271 had a related patch set uploaded (by Esanders; owner: Esanders):
[mediawiki/skins/MinervaNeue@master] Remove obsolete aliases from closures

https://gerrit.wikimedia.org/r/474271

Change 474275 had a related patch set uploaded (by Esanders; owner: Esanders):
[mediawiki/skins/Timeless@master] Remove obsolete aliases from closures

https://gerrit.wikimedia.org/r/474275

Change 474276 had a related patch set uploaded (by Esanders; owner: Esanders):
[mediawiki/skins/Vector@master] Remove obsolete aliases from closures

https://gerrit.wikimedia.org/r/474276

Change 474282 had a related patch set uploaded (by Esanders; owner: Esanders):
[mediawiki/extensions/MobileFrontend@master] Remove obsolete aliases from closures

https://gerrit.wikimedia.org/r/474282

Change 474286 had a related patch set uploaded (by Esanders; owner: Esanders):
[mediawiki/extensions/Score@master] Remove obsolete aliases from closures

https://gerrit.wikimedia.org/r/474286

Change 474292 had a related patch set uploaded (by Esanders; owner: Esanders):
[mediawiki/extensions/RevisionSlider@master] Remove obsolete aliases from closures

https://gerrit.wikimedia.org/r/474292

Change 474297 had a related patch set uploaded (by Esanders; owner: Esanders):
[mediawiki/extensions/TemplateWizard@master] Remove obsolete aliases from closures

https://gerrit.wikimedia.org/r/474297

Change 474298 had a related patch set uploaded (by Esanders; owner: Esanders):
[mediawiki/extensions/wikihiero@master] Remove obsolete aliases from closures

https://gerrit.wikimedia.org/r/474298

Change 474276 merged by jenkins-bot:
[mediawiki/skins/Vector@master] Remove obsolete aliases from closures

https://gerrit.wikimedia.org/r/474276

Change 474271 merged by jenkins-bot:
[mediawiki/skins/MinervaNeue@master] Remove obsolete aliases from closures

https://gerrit.wikimedia.org/r/474271

Change 474275 merged by jenkins-bot:
[mediawiki/skins/Timeless@master] Remove obsolete aliases from closures

https://gerrit.wikimedia.org/r/474275

Change 474297 merged by jenkins-bot:
[mediawiki/extensions/TemplateWizard@master] Remove obsolete aliases from closures

https://gerrit.wikimedia.org/r/474297

Change 474298 merged by jenkins-bot:
[mediawiki/extensions/wikihiero@master] Remove obsolete aliases from closures

https://gerrit.wikimedia.org/r/474298

Change 474292 merged by jenkins-bot:
[mediawiki/extensions/RevisionSlider@master] Remove obsolete aliases from closures

https://gerrit.wikimedia.org/r/474292

Change 475503 had a related patch set uploaded (by Esanders; owner: Esanders):
[mediawiki/extensions/AbuseFilter@master] Remove obsolete aliases from closures

https://gerrit.wikimedia.org/r/475503

Change 475503 merged by jenkins-bot:
[mediawiki/extensions/AbuseFilter@master] Remove obsolete aliases from closures

https://gerrit.wikimedia.org/r/475503

Change 476307 had a related patch set uploaded (by Esanders; owner: Esanders):
[mediawiki/extensions/BetaFeatures@master] Remove obsolete aliases from closures

https://gerrit.wikimedia.org/r/476307

Change 476307 merged by jenkins-bot:
[mediawiki/extensions/BetaFeatures@master] Remove obsolete aliases from closures

https://gerrit.wikimedia.org/r/476307

Change 473615 merged by jenkins-bot:
[mediawiki/extensions/WikimediaMessages@master] Remove obsolete aliases from closures, and fix line lengths

https://gerrit.wikimedia.org/r/473615

Change 476616 had a related patch set uploaded (by Esanders; owner: Esanders):
[mediawiki/extensions/GuidedTour@master] Remove obsolete aliases from closures

https://gerrit.wikimedia.org/r/476616

Change 476616 merged by jenkins-bot:
[mediawiki/extensions/GuidedTour@master] Remove obsolete aliases from closures

https://gerrit.wikimedia.org/r/476616

Change 478038 had a related patch set uploaded (by Fomafix; owner: Fomafix):
[mediawiki/extensions/ReplaceText@master] Remove obsolete aliases from closures

https://gerrit.wikimedia.org/r/478038

Change 478042 had a related patch set uploaded (by Fomafix; owner: Fomafix):
[mediawiki/extensions/CategoryTree@master] Remove obsolete aliases from closures

https://gerrit.wikimedia.org/r/478042

Change 478042 merged by jenkins-bot:
[mediawiki/extensions/CategoryTree@master] Remove obsolete aliases from closures

https://gerrit.wikimedia.org/r/478042

Change 478038 merged by jenkins-bot:
[mediawiki/extensions/ReplaceText@master] Remove obsolete aliases from closures

https://gerrit.wikimedia.org/r/478038

Change 472167 merged by jenkins-bot:
[mediawiki/extensions/CentralNotice@master] Remove obsolete aliases from closures

https://gerrit.wikimedia.org/r/472167

Change 478398 had a related patch set uploaded (by Fomafix; owner: Fomafix):
[mediawiki/extensions/TocTree@master] Remove obsolete aliases from closures

https://gerrit.wikimedia.org/r/478398

Change 478398 merged by jenkins-bot:
[mediawiki/extensions/TocTree@master] Remove obsolete aliases from closures

https://gerrit.wikimedia.org/r/478398

Change 478775 had a related patch set uploaded (by Esanders; owner: Esanders):
[mediawiki/extensions/WikibaseLexeme@master] Remove obsolete aliases from closures

https://gerrit.wikimedia.org/r/478775

Change 478775 merged by jenkins-bot:
[mediawiki/extensions/WikibaseLexeme@master] Remove obsolete aliases from closures

https://gerrit.wikimedia.org/r/478775

Change 474282 merged by Jdlrobson:
[mediawiki/extensions/MobileFrontend@master] Remove obsolete aliases from closures

https://gerrit.wikimedia.org/r/474282

Change 480118 had a related patch set uploaded (by Esanders; owner: Esanders):
[data-values/value-view@master] Remove obsolete aliases from closures

https://gerrit.wikimedia.org/r/480118

Change 481229 had a related patch set uploaded (by Krinkle; owner: Krinkle):
[mediawiki/extensions/QuickSurveys@master] build: Update eslint rules and remove redundant aliases

https://gerrit.wikimedia.org/r/481229

Change 481229 merged by Krinkle:
[mediawiki/extensions/QuickSurveys@master] build: Update eslint rules and remove redundant aliases

https://gerrit.wikimedia.org/r/481229

Change 480118 merged by jenkins-bot:
[data-values/value-view@master] Remove obsolete aliases from closures

https://gerrit.wikimedia.org/r/480118

Change 482487 had a related patch set uploaded (by Krinkle; owner: Krinkle):
[mediawiki/extensions/examples@master] Update Example extension with various best practices

https://gerrit.wikimedia.org/r/482487

Change 455580 had a related patch set uploaded (by Krinkle; owner: Alangi Derick):
[mediawiki/extensions/examples@master] Update Example extension with various best practices

https://gerrit.wikimedia.org/r/455580

Change 482487 abandoned by Krinkle:
Update Example extension with various best practices

Reason:
Merged into I82ee745b99398b362

https://gerrit.wikimedia.org/r/482487

Change 455580 merged by jenkins-bot:
[mediawiki/extensions/examples@master] Update Example extension with various best practices

https://gerrit.wikimedia.org/r/455580

Change 483051 had a related patch set uploaded (by Krinkle; owner: Krinkle):
[mediawiki/extensions/VipsScaler@master] build: Structure updates

https://gerrit.wikimedia.org/r/483051

Change 483051 merged by jenkins-bot:
[mediawiki/extensions/VipsScaler@master] build: Structure updates

https://gerrit.wikimedia.org/r/483051

Change 483530 had a related patch set uploaded (by Krinkle; owner: Krinkle):
[mediawiki/extensions/ApiFeatureUsage@master] build: Structure update

https://gerrit.wikimedia.org/r/483530

Change 483530 merged by jenkins-bot:
[mediawiki/extensions/ApiFeatureUsage@master] build: Structure update

https://gerrit.wikimedia.org/r/483530

Change 492220 had a related patch set uploaded (by Krinkle; owner: Krinkle):
[mediawiki/extensions/SecurePoll@master] Remove obsolete aliases from closures in JS code

https://gerrit.wikimedia.org/r/492220

Change 492221 had a related patch set uploaded (by Krinkle; owner: Krinkle):
[mediawiki/extensions/ShortUrl@master] Remove obsolete aliases from closures in JS code

https://gerrit.wikimedia.org/r/492221

Change 492228 had a related patch set uploaded (by Krinkle; owner: Krinkle):
[mediawiki/extensions/ReadingLists@master] build: Remove unused jquery/mw from eslint config

https://gerrit.wikimedia.org/r/492228

Change 492228 merged by jenkins-bot:
[mediawiki/extensions/ReadingLists@master] build: Remove unused jquery/mw from eslint config

https://gerrit.wikimedia.org/r/492228

Change 492220 merged by jenkins-bot:
[mediawiki/extensions/SecurePoll@master] Remove obsolete aliases from closures in JS code

https://gerrit.wikimedia.org/r/492220

Change 492221 merged by jenkins-bot:
[mediawiki/extensions/ShortUrl@master] Remove obsolete aliases from closures in JS code

https://gerrit.wikimedia.org/r/492221

Change 497666 had a related patch set uploaded (by Krinkle; owner: Krinkle):
[mediawiki/extensions/CentralAuth@master] build: Update eslint config and apply newer conventions

https://gerrit.wikimedia.org/r/497666

Change 497666 merged by jenkins-bot:
[mediawiki/extensions/CentralAuth@master] build: Update eslint config and apply newer conventions

https://gerrit.wikimedia.org/r/497666

Change 543800 had a related patch set uploaded (by Thiemo Kreuz (WMDE); owner: Thiemo Kreuz (WMDE)):
[mediawiki/extensions/Popups@master] Remove obsolete mediaWiki and jQuery aliases

https://gerrit.wikimedia.org/r/543800

Change 543800 merged by jenkins-bot:
[mediawiki/extensions/Popups@master] Remove obsolete mediaWiki and jQuery aliases

https://gerrit.wikimedia.org/r/543800