Move check for 'usebetatoolbar' from JS to PHP

This change avoids useless loading of the module 'ext.CodeMirror'.

Change-Id: I2637487b72c028d272748f2891239401412f77b5
This commit is contained in:
Fomafix 2019-03-11 07:17:13 +01:00 committed by TheDJ
parent 652c4585bd
commit b17c8b7557
2 changed files with 5 additions and 2 deletions

View file

@ -14,6 +14,10 @@ class CodeMirrorHooks {
if ( in_array( 'ext.codeEditor', $out->getModules() ) ) {
return false;
}
// Disable CodeMirror when the WikiEditor toolbar is not enabled in preferences
if ( !$out->getUser()->getOption( 'usebetatoolbar' ) ) {
return false;
}
$context = $out->getContext();
return in_array( Action::getActionName( $context ), [ 'edit', 'submit' ] ) &&
// CodeMirror on textarea wikitext editors doesn't support RTL (T170001)

View file

@ -9,8 +9,7 @@
];
// Exit if WikiEditor is disabled
// usebetatoolbar can be the string "0" if the user disabled the preference - Bug T54542#555387
if ( !( mw.loader.getState( 'ext.wikiEditor' ) && mw.user.options.get( 'usebetatoolbar' ) > 0 ) ) {
if ( !mw.loader.getState( 'ext.wikiEditor' ) ) {
return;
}