From 5888ec9f29cd65e76f573fc0a8bc55c47ecf76e8 Mon Sep 17 00:00:00 2001 From: Umherirrender Date: Sat, 6 May 2023 23:11:13 +0200 Subject: [PATCH] Replace deprecated Hooks::run Bug: T335536 Change-Id: I6968c26df6819f0c83105e92c03d1d204f90db27 (cherry picked from commit 35660f4e781346a402b5b5c49aad745306a55369) --- extension.json | 3 ++- src/HookHandlers/ParserHooksHandler.php | 14 ++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/extension.json b/extension.json index 352347910..6cff01db6 100644 --- a/extension.json +++ b/extension.json @@ -39,7 +39,8 @@ "class": "MediaWiki\\Extension\\Math\\HookHandlers\\ParserHooksHandler", "services": [ "Math.RendererFactory", - "UserOptionsLookup" + "UserOptionsLookup", + "HookContainer" ] }, "PreferencesHooksHandler": { diff --git a/src/HookHandlers/ParserHooksHandler.php b/src/HookHandlers/ParserHooksHandler.php index f730d9d22..cede00e36 100644 --- a/src/HookHandlers/ParserHooksHandler.php +++ b/src/HookHandlers/ParserHooksHandler.php @@ -3,7 +3,6 @@ namespace MediaWiki\Extension\Math\HookHandlers; use FatalError; -use Hooks as MWHooks; use MediaWiki\Extension\Math\MathConfig; use MediaWiki\Extension\Math\MathMathML; use MediaWiki\Extension\Math\MathMathMLCli; @@ -12,6 +11,7 @@ use MediaWiki\Extension\Math\Render\RendererFactory; use MediaWiki\Hook\ParserAfterTidyHook; use MediaWiki\Hook\ParserFirstCallInitHook; use MediaWiki\Hook\ParserOptionsRegisterHook; +use MediaWiki\HookContainer\HookContainer; use MediaWiki\Logger\LoggerFactory; use MediaWiki\User\UserOptionsLookup; use MWException; @@ -39,16 +39,22 @@ class ParserHooksHandler implements /** @var UserOptionsLookup */ private $userOptionsLookup; + /** @var HookContainer */ + private $hookContainer; + /** * @param RendererFactory $rendererFactory * @param UserOptionsLookup $userOptionsLookup + * @param HookContainer $hookContainer */ public function __construct( RendererFactory $rendererFactory, - UserOptionsLookup $userOptionsLookup + UserOptionsLookup $userOptionsLookup, + HookContainer $hookContainer ) { $this->rendererFactory = $rendererFactory; $this->userOptionsLookup = $userOptionsLookup; + $this->hookContainer = $hookContainer; } /** @@ -133,8 +139,8 @@ class ParserHooksHandler implements $renderer->addTrackingCategories( $parser ); return $renderer->getLastError(); } - // TODO: Convert to a new style hook system and inject HookContainer - MWHooks::run( 'MathFormulaPostRender', + // TODO: Convert to a new style hook system + $this->hookContainer->run( 'MathFormulaPostRender', [ $parser, $renderer, &$renderedMath ] ); // Enables indexing of math formula