Page MenuHomePhabricator

Support GlobalPreferences in VisualEditor when setting preferences
Open, Needs TriagePublic

Description

If a user has overridden a preference globally, then any attempts to set the preference using the API would fail.

The solution is to either set a local override for that wiki for the preference or set the global preference for the user.

Local override acts as an exception to the global preference value on a per-wiki basis.
Global preference is set across all projects.

GlobalPrefs APIs are documented here: https://www.mediawiki.org/wiki/Extension:GlobalPreferences/API

Event Timeline

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

The preferences that VE changes directly are mostly not settable anywhere else in the UI, so unless the user does a custom API call, they wouldn't be able to set them globally.

CCing @matmarex

To be exact, VE sets the following preferences via API: [I've just made this list by searching our source code]

visualeditor-findAndReplace-diacritic
visualeditor-findAndReplace-findText
visualeditor-findAndReplace-matchCase
visualeditor-findAndReplace-regex
visualeditor-findAndReplace-replaceText
visualeditor-findAndReplace-word
visualeditor-hidebetawelcome
visualeditor-hidesourceswitchpopup
visualeditor-hidevisualswitchpopup
visualeditor-hidetabdialog
visualeditor-hideusered
visualeditor-editor
visualeditor-tabs
visualeditor-diffmode-historical
visualeditor-diffmode-source
visualeditor-diffmode-visual

Out of them, all but visualeditor-tabs are registered as 'type' => 'api' preferences, so users should not be able to make them global preferences except via API. And if they did, I'm not even sure what we should do. We could maybe show an error message, but that seems like it would be rather annoying if you really wanted that preferences to be global. I don't think we should set most of them globally, nor override them if they are made global. @Niharika Is there a way for us to define that they can not be set globally?

For visualeditor-tabs, we could possibly skip the dialog that results in setting this preference if it is already set globally? However, that is guarded by some nasty code where we apparently migrated some preferences regarding to multiple/single edit tab, we'd need to investigate this to decide if that's a good idea.

For many of the visualeditor-hide... preferences, it might actually make sense to set them globally; task T135767 basically asks for exactly that for visualeditor-hidebetawelcome. We'd need to investigate the others.