Replace deprecated Hooks::run

Bug: T335536
Change-Id: I6968c26df6819f0c83105e92c03d1d204f90db27
(cherry picked from commit 35660f4e78)
This commit is contained in:
Umherirrender 2023-05-06 23:11:13 +02:00
parent 79285fbb6a
commit 5888ec9f29
2 changed files with 12 additions and 5 deletions

View file

@ -39,7 +39,8 @@
"class": "MediaWiki\\Extension\\Math\\HookHandlers\\ParserHooksHandler", "class": "MediaWiki\\Extension\\Math\\HookHandlers\\ParserHooksHandler",
"services": [ "services": [
"Math.RendererFactory", "Math.RendererFactory",
"UserOptionsLookup" "UserOptionsLookup",
"HookContainer"
] ]
}, },
"PreferencesHooksHandler": { "PreferencesHooksHandler": {

View file

@ -3,7 +3,6 @@
namespace MediaWiki\Extension\Math\HookHandlers; namespace MediaWiki\Extension\Math\HookHandlers;
use FatalError; use FatalError;
use Hooks as MWHooks;
use MediaWiki\Extension\Math\MathConfig; use MediaWiki\Extension\Math\MathConfig;
use MediaWiki\Extension\Math\MathMathML; use MediaWiki\Extension\Math\MathMathML;
use MediaWiki\Extension\Math\MathMathMLCli; use MediaWiki\Extension\Math\MathMathMLCli;
@ -12,6 +11,7 @@ use MediaWiki\Extension\Math\Render\RendererFactory;
use MediaWiki\Hook\ParserAfterTidyHook; use MediaWiki\Hook\ParserAfterTidyHook;
use MediaWiki\Hook\ParserFirstCallInitHook; use MediaWiki\Hook\ParserFirstCallInitHook;
use MediaWiki\Hook\ParserOptionsRegisterHook; use MediaWiki\Hook\ParserOptionsRegisterHook;
use MediaWiki\HookContainer\HookContainer;
use MediaWiki\Logger\LoggerFactory; use MediaWiki\Logger\LoggerFactory;
use MediaWiki\User\UserOptionsLookup; use MediaWiki\User\UserOptionsLookup;
use MWException; use MWException;
@ -39,16 +39,22 @@ class ParserHooksHandler implements
/** @var UserOptionsLookup */ /** @var UserOptionsLookup */
private $userOptionsLookup; private $userOptionsLookup;
/** @var HookContainer */
private $hookContainer;
/** /**
* @param RendererFactory $rendererFactory * @param RendererFactory $rendererFactory
* @param UserOptionsLookup $userOptionsLookup * @param UserOptionsLookup $userOptionsLookup
* @param HookContainer $hookContainer
*/ */
public function __construct( public function __construct(
RendererFactory $rendererFactory, RendererFactory $rendererFactory,
UserOptionsLookup $userOptionsLookup UserOptionsLookup $userOptionsLookup,
HookContainer $hookContainer
) { ) {
$this->rendererFactory = $rendererFactory; $this->rendererFactory = $rendererFactory;
$this->userOptionsLookup = $userOptionsLookup; $this->userOptionsLookup = $userOptionsLookup;
$this->hookContainer = $hookContainer;
} }
/** /**
@ -133,8 +139,8 @@ class ParserHooksHandler implements
$renderer->addTrackingCategories( $parser ); $renderer->addTrackingCategories( $parser );
return $renderer->getLastError(); return $renderer->getLastError();
} }
// TODO: Convert to a new style hook system and inject HookContainer // TODO: Convert to a new style hook system
MWHooks::run( 'MathFormulaPostRender', $this->hookContainer->run( 'MathFormulaPostRender',
[ $parser, $renderer, &$renderedMath ] [ $parser, $renderer, &$renderedMath ]
); // Enables indexing of math formula ); // Enables indexing of math formula