Page MenuHomePhabricator

mw.config variables for use in mediawiki.Title should use package files
Open, Needs TriagePublic

Description

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

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

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

Change 724382 had a related patch set uploaded (by DannyS712; author: DannyS712):

[mediawiki/core@master] Moving mediawiki.Title configuration settings to package files

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

DannyS712 added a subscriber: Jack_who_built_the_house.

Per global search, used by some onwiki scripts, including use of wgExtraSignatureNamespaces in convenient discussions scripts (cc @Jack_who_built_the_house)

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.

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. :(

@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!

@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.

@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.

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.