phabricator.wikimedia.org

⚓ T292011 mw.config variables for use in mediawiki.Title should use package files

  • ️Tue Sep 28 2021

mw.config variables for use in mediawiki.Title should use package files

Currently, on all responses mw.config includes configuration variables wgExtraSignatureNamespaces, wgLegalTitleChars, and wgIllegalFileChars. These are documented[1] as being

@internal For mediawiki.Title

We should switch to providing them via package files instead, so that they are only loaded when the mediawiki.Title module is used.
Uses in javascript

  • wgExtraSignatureNamespaces - correctly only used by mediawiki.Title
  • wgLegalTitleChars - correctly only used by mediawiki.Title
  • wgIllegalFileChars - also being used by UploadWizard extension (deployed) and MediaUploader (not deployed)

Proposal:

  • Switch extensions (at least UploadWizard) to use package files with injected config
  • Switch mediawiki.Title to use package files with injected config, and remove from mw.config (with a mention in the release notes just in case)

[1] https://gerrit.wikimedia.org/g/mediawiki/core/+/3ff9183d2453413e7c8c550232918d11cfd1eb1b/includes/resourceloader/ResourceLoader.php#1977

Event Timeline

Comment Actions

Hmm, except both of the extensions (it looks like MediaUpload's code is a copy of UploadWizard) are using scripts instead of packageFiles, so that might not be easy to do. Maybe we can reuse the mw.Title validation of illegal file characters instead of doing it in the extensions too? Don't really see how to do that. Perhaps instead we can have mw.Title add the wgIllegalFileChars to mw.config, so that anything depending on it can also use it...

We can start by switching mediawiki.Title to package files and dropping the first two configs (extra signatures and legal title chars) from mw.config, and deal with illegal file chars later

Comment Actions

Thanks for the ping. To Convenient-Discussions, the unavailability of wgExtraSignatureNamespaces as a config value will mean that in the general case, CD will have to wait until the modules (lots of them) are loaded to tell if the current page is a talk page, where CD should run. Luckily, mediawiki.Title is usually already loaded by the time CD runs, so I will just run a check for mw.loader.getState('mediawiki.Title') === 'ready' and then do the namespace check. If mediawiki.Title is not ready, only then the modules will be requested.

Comment Actions

Hmm, except both of the extensions (it looks like MediaUpload's code is a copy of UploadWizard)

JS code should be almost identical, for now. Any fix for UW should be easily applicable to MU.

As for the solution, I don't really care as long as it works. There are some methods in Title that may be able to help with this, but currently I do not have the time to fiddle with this. :(

Comment Actions

@DannyS712 Hi. Re: Tech News - What would you suggest as the content, and When should it be included?
(I'm currently editing the edition that is due to be frozen-for-translations tomorrow (~25hours from now), and to be delivered on Monday). Thanks!

Comment Actions

@DannyS712 Hi. Re: Tech News - What would you suggest as the content, and When should it be included?
(I'm currently editing the edition that is due to be frozen-for-translations tomorrow (~25hours from now), and to be delivered on Monday). Thanks!

Lets wait until at least next week. As for content, something also the lines of

The JavaScript mw.config no longer contains the values for wgExtraSignatureNamespaces, wgLegalTitleChars, and wgIllegalFileChars. These had previously be documented as for internal use and were not part of the "stable" variables available for use in wiki JavaScript.

Comment Actions

@DannyS712 Hi. Re: Tech News - What would you suggest as the content, and When should it be included?
(I'm currently editing the edition that is due to be frozen-for-translations tomorrow (~25hours from now), and to be delivered on Monday). Thanks!

Lets wait until at least next week. As for content, something also the lines of

The JavaScript mw.config no longer contains the values for wgExtraSignatureNamespaces, wgLegalTitleChars, and wgIllegalFileChars. These had previously be documented as for internal use and were not part of the "stable" variables available for use in wiki JavaScript.

Actually, you can probably announce now that they will be removed soon

The JavaScript mw.config will soon no longer contain the values for wgExtraSignatureNamespaces, wgLegalTitleChars, and wgIllegalFileChars. These are currently documented as for internal use and are not part of the "stable" variables available for use in wiki JavaScript.

Comment Actions

I'm sorry that I haven't handled this task. I recently returned from a long bout of unexpected inactivity, and while I plan to resume my contributions here on Phabricator its unfair to claim tasks that I might not work on when others may be interested in handling them. I'm removing myself as the assignee in a batch-action, but if someone feels that I really should be the one to handle this task feel free to re-assign me and I'll take a look.

Content licensed under Creative Commons Attribution-ShareAlike (CC BY-SA) 4.0 unless otherwise noted; code licensed under GNU General Public License (GPL) 2.0 or later and other open source licenses. By using this site, you agree to the Terms of Use, Privacy Policy, and Code of Conduct. · Wikimedia Foundation · Privacy Policy · Code of Conduct · Terms of Use · Disclaimer · CC-BY-SA · GPL · Credits