From 3f905c27470dad8aa9f400e176e99b139f5b0cf3 Mon Sep 17 00:00:00 2001 From: Fomafix Date: Wed, 24 Jul 2024 16:28:05 +0000 Subject: [PATCH] Use $this->getServiceContainer() in maintenance Change-Id: I723fa230e525970d7e7600dee37fbfae62911a49 --- maintenance/JsonToMathML.php | 3 +-- tests/wfTest.php | 9 ++++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/maintenance/JsonToMathML.php b/maintenance/JsonToMathML.php index 24854c318..d66fb9dc6 100644 --- a/maintenance/JsonToMathML.php +++ b/maintenance/JsonToMathML.php @@ -19,7 +19,6 @@ */ use MediaWiki\Extension\Math\MathRenderer; -use MediaWiki\MediaWikiServices; require_once __DIR__ . '/../../../maintenance/Maintenance.php'; @@ -209,7 +208,7 @@ class JsonToMathML extends Maintenance { $tex = "\\ce{ " . $tex . " }"; } /** @var MathRenderer $renderer */ - $renderer = MediaWikiServices::getInstance()->get( 'Math.RendererFactory' ) + $renderer = $this->getServiceContainer()->get( 'Math.RendererFactory' ) ->getRenderer( $tex, $params, $renderingMode ); $renderer->render(); $mml = $renderer->getMathml(); diff --git a/tests/wfTest.php b/tests/wfTest.php index 4914bd8a7..d72594a70 100644 --- a/tests/wfTest.php +++ b/tests/wfTest.php @@ -6,7 +6,6 @@ require_once __DIR__ . '/../../../maintenance/Maintenance.php'; use MediaWiki\Extension\Math\MathConfig; use MediaWiki\Extension\Math\MathMathMLCli; -use MediaWiki\MediaWikiServices; use MediaWiki\Parser\Parser; use MediaWiki\Parser\Sanitizer; use MediaWiki\Title\Title; @@ -26,7 +25,7 @@ class WfTest extends Maintenance { $this->addOption( 'user', "User with rights to view the page", false, true, "u" ); } - private static function getMathTagsFromPage( $titleString ) { + private function getMathTagsFromPage( $titleString ) { global $wgEnableScaryTranscluding; $title = Title::newFromText( $titleString ); if ( $title->exists() ) { @@ -38,7 +37,7 @@ class WfTest extends Maintenance { } else { if ( $title == self::REFERENCE_PAGE ) { $wgEnableScaryTranscluding = true; - $parser = MediaWikiServices::getInstance()->getParserFactory()->create(); + $parser = $this->getServiceContainer()->getParserFactory()->create(); $wikiText = $parser->interwikiTransclude( $title, 'raw' ); } else { return 'Page does not exist'; @@ -59,7 +58,7 @@ class WfTest extends Maintenance { $offset = $this->getOption( 'offset', 0 ); $length = $this->getOption( 'length', PHP_INT_MAX ); $userName = $this->getOption( 'user', 'Maintenance script' ); - $allEquations = self::getMathTagsFromPage( $page ); + $allEquations = $this->getMathTagsFromPage( $page ); if ( !is_array( $allEquations ) ) { echo "Could not get equations from page '$page'\n"; echo $allEquations . PHP_EOL; @@ -70,7 +69,7 @@ class WfTest extends Maintenance { } $i = 0; $rend = []; - $rendererFactory = MediaWikiServices::getInstance()->get( 'Math.RendererFactory' ); + $rendererFactory = $this->getServiceContainer()->get( 'Math.RendererFactory' ); foreach ( array_slice( $allEquations, $offset, $length, true ) as $input ) { $renderer = $rendererFactory->getRenderer( $input[1], $input[2], MathConfig::MODE_MATHML ); if ( $renderer->render() ) {