Hooks: restore respect of $wgCodeMirrorLineNumberingNamespaces in CM5

Restore the ResourceLoaderGetConfigVars hook which CodeMirror 5 still
relies on when it checks $wgCodeMirrorLineNumberingNamespaces.
In CM6, this is set in the config provided by DataScript.php.

Partially reverts I67518c0968

Bug: T347211
Follow-Up: I67518c0968f64c79e290f57b4884d30a161212d3
Change-Id: Id34858da68f7e08d16f8d1312bbbd355ccf8d140
This commit is contained in:
MusikAnimal 2024-03-27 22:36:25 -04:00 committed by Tim Starling
parent 3c8f71eb13
commit c0155b0755
2 changed files with 18 additions and 1 deletions

View file

@ -280,7 +280,8 @@
"Hooks": { "Hooks": {
"EditPage::showEditForm:initial": "main", "EditPage::showEditForm:initial": "main",
"EditPage::showReadOnlyForm:initial": "main", "EditPage::showReadOnlyForm:initial": "main",
"GetPreferences": "main" "GetPreferences": "main",
"ResourceLoaderGetConfigVars": "main"
}, },
"HookHandlers": { "HookHandlers": {
"main": { "main": {

View file

@ -11,6 +11,7 @@ use MediaWiki\Hook\EditPage__showEditForm_initialHook;
use MediaWiki\Hook\EditPage__showReadOnlyForm_initialHook; use MediaWiki\Hook\EditPage__showReadOnlyForm_initialHook;
use MediaWiki\Output\OutputPage; use MediaWiki\Output\OutputPage;
use MediaWiki\Preferences\Hook\GetPreferencesHook; use MediaWiki\Preferences\Hook\GetPreferencesHook;
use MediaWiki\ResourceLoader\Hook\ResourceLoaderGetConfigVarsHook;
use MediaWiki\User\Options\UserOptionsLookup; use MediaWiki\User\Options\UserOptionsLookup;
use MediaWiki\User\User; use MediaWiki\User\User;
@ -20,6 +21,7 @@ use MediaWiki\User\User;
class Hooks implements class Hooks implements
EditPage__showEditForm_initialHook, EditPage__showEditForm_initialHook,
EditPage__showReadOnlyForm_initialHook, EditPage__showReadOnlyForm_initialHook,
ResourceLoaderGetConfigVarsHook,
GetPreferencesHook GetPreferencesHook
{ {
@ -141,6 +143,20 @@ class Hooks implements
return $this->useV6 || $out->getRequest()->getRawVal( 'cm6enable' ); return $this->useV6 || $out->getRequest()->getRawVal( 'cm6enable' );
} }
/**
* Hook handler for enabling bracket matching.
*
* TODO: Remove after migration to CodeMirror 6 is complete.
*
* @param array &$vars Array of variables to be added into the output of the startup module
* @param string $skin
* @param Config $config
* @return void This hook must not abort, it must return no value
*/
public function onResourceLoaderGetConfigVars( array &$vars, $skin, Config $config ): void {
$vars['wgCodeMirrorLineNumberingNamespaces'] = $config->get( 'CodeMirrorLineNumberingNamespaces' );
}
/** /**
* GetPreferences hook handler * GetPreferences hook handler
* *