getPreferredEditor() shouldn't return VisualEditor if it's disabled by the user

Bug: T257234
Change-Id: I68002cc7bf6935bad705497df6531e3611bd2ca6
This commit is contained in:
Bartosz Dziewoński 2020-07-07 21:58:12 +02:00
parent 4ea0cf0cab
commit b819b8a657

View file

@ -365,6 +365,13 @@ class VisualEditorHooks {
public static function getPreferredEditor( public static function getPreferredEditor(
User $user, WebRequest $req, $useWikitextInMultiTab = false User $user, WebRequest $req, $useWikitextInMultiTab = false
) { ) {
// VisualEditor shouldn't even call this method when it's disabled, but it is a public API for
// other extensions (e.g. DiscussionTools), and the editor preferences might have surprising
// values if the user has tried VisualEditor in the past and then disabled it. (T257234)
if ( !self::enabledForUser( $user ) ) {
return 'wikitext';
}
switch ( $user->getOption( 'visualeditor-tabs' ) ) { switch ( $user->getOption( 'visualeditor-tabs' ) ) {
case 'prefer-ve': case 'prefer-ve':
return 'visualeditor'; return 'visualeditor';