From 72e956c82aa9256e64db46419a8ef88d852548a5 Mon Sep 17 00:00:00 2001 From: Umherirrender Date: Mon, 14 Aug 2023 21:11:29 +0200 Subject: [PATCH] Use HookHandlers for Scribunto hook Cannot use the interface as the required version is not reached yet. Cannot bump due to use in fundraising Bug: T271022 Change-Id: I78771f948d4d1e03fc7565525f562c61af9d749a --- extension.json | 5 ++++- includes/Hooks.php | 14 -------------- includes/ScribuntoHooks.php | 26 ++++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 15 deletions(-) create mode 100644 includes/ScribuntoHooks.php diff --git a/extension.json b/extension.json index 9e69d038..36ae03ce 100644 --- a/extension.json +++ b/extension.json @@ -33,7 +33,7 @@ "Hooks": { "ParserTestGlobals": "ParserFunctionsHookHandler", "ParserFirstCallInit": "ParserFunctionsHookHandler", - "ScribuntoExternalLibraries": "MediaWiki\\Extension\\ParserFunctions\\Hooks::onScribuntoExternalLibraries" + "ScribuntoExternalLibraries": "ParserFunctionsScribuntoHookHandler" }, "HookHandlers": { "ParserFunctionsHookHandler": { @@ -41,6 +41,9 @@ "services": [ "MainConfig" ] + }, + "ParserFunctionsScribuntoHookHandler": { + "class": "MediaWiki\\Extension\\ParserFunctions\\ScribuntoHooks" } }, "AutoloadNamespaces": { diff --git a/includes/Hooks.php b/includes/Hooks.php index 29bc7376..e216ca11 100644 --- a/includes/Hooks.php +++ b/includes/Hooks.php @@ -67,18 +67,4 @@ class Hooks implements $parser->setFunctionHook( 'urldecode', [ ParserFunctions::class, 'runUrlDecode' ] ); } } - - /** - * Registers ParserFunctions' lua function with Scribunto - * - * @see https://www.mediawiki.org/wiki/Extension:Scribunto/ScribuntoExternalLibraries - * - * @param string $engine - * @param string[] &$extraLibraries - */ - public static function onScribuntoExternalLibraries( $engine, array &$extraLibraries ) { - if ( $engine === 'lua' ) { - $extraLibraries['mw.ext.ParserFunctions'] = LuaLibrary::class; - } - } } diff --git a/includes/ScribuntoHooks.php b/includes/ScribuntoHooks.php new file mode 100644 index 00000000..bcfa6ef6 --- /dev/null +++ b/includes/ScribuntoHooks.php @@ -0,0 +1,26 @@ +