From c0155b07554605964e41eb1db919da2a1bc75af0 Mon Sep 17 00:00:00 2001 From: MusikAnimal Date: Wed, 27 Mar 2024 22:36:25 -0400 Subject: [PATCH] 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 --- extension.json | 3 ++- includes/Hooks.php | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/extension.json b/extension.json index 40c1c3de..26f30f38 100644 --- a/extension.json +++ b/extension.json @@ -280,7 +280,8 @@ "Hooks": { "EditPage::showEditForm:initial": "main", "EditPage::showReadOnlyForm:initial": "main", - "GetPreferences": "main" + "GetPreferences": "main", + "ResourceLoaderGetConfigVars": "main" }, "HookHandlers": { "main": { diff --git a/includes/Hooks.php b/includes/Hooks.php index 1f70dbff..21bd7593 100644 --- a/includes/Hooks.php +++ b/includes/Hooks.php @@ -11,6 +11,7 @@ use MediaWiki\Hook\EditPage__showEditForm_initialHook; use MediaWiki\Hook\EditPage__showReadOnlyForm_initialHook; use MediaWiki\Output\OutputPage; use MediaWiki\Preferences\Hook\GetPreferencesHook; +use MediaWiki\ResourceLoader\Hook\ResourceLoaderGetConfigVarsHook; use MediaWiki\User\Options\UserOptionsLookup; use MediaWiki\User\User; @@ -20,6 +21,7 @@ use MediaWiki\User\User; class Hooks implements EditPage__showEditForm_initialHook, EditPage__showReadOnlyForm_initialHook, + ResourceLoaderGetConfigVarsHook, GetPreferencesHook { @@ -141,6 +143,20 @@ class Hooks implements 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 *