* @see Content::getSection()
*/
public function getSection( $sectionId ) {
- global $wgParser;
-
$text = $this->getText();
- $sect = $wgParser->getSection( $text, $sectionId, false );
+ $sect = MediaWikiServices::getInstance()->getParser()
+ ->getSection( $text, $sectionId, false );
if ( $sect === false ) {
return false;
}
} else {
# Replacing an existing section; roll out the big guns
- global $wgParser;
-
- $text = $wgParser->replaceSection( $oldtext, $sectionId, $text );
+ $text = MediaWikiServices::getInstance()->getParser()
+ ->replaceSection( $oldtext, $sectionId, $text );
}
$newContent = new static( $text );
* @return Content
*/
public function preSaveTransform( Title $title, User $user, ParserOptions $popts ) {
- global $wgParser;
-
$text = $this->getText();
- $pst = $wgParser->preSaveTransform( $text, $title, $user, $popts );
+
+ $parser = MediaWikiServices::getInstance()->getParser();
+ $pst = $parser->preSaveTransform( $text, $title, $user, $popts );
if ( $text === $pst ) {
return $this;
$ret = new static( $pst );
- if ( $wgParser->getOutput()->getFlag( 'user-signature' ) ) {
+ if ( $parser->getOutput()->getFlag( 'user-signature' ) ) {
$ret->hadSignature = true;
}
* @return Content
*/
public function preloadTransform( Title $title, ParserOptions $popts, $params = [] ) {
- global $wgParser;
-
$text = $this->getText();
- $plt = $wgParser->getPreloadText( $text, $title, $popts, $params );
+ $plt = MediaWikiServices::getInstance()->getParser()
+ ->getPreloadText( $text, $title, $popts, $params );
return new static( $plt );
}
/**
* Returns a ParserOutput object resulting from parsing the content's text
- * using $wgParser.
+ * using the global Parser service.
*
* @param Title $title
* @param int $revId Revision to pass to the parser (default: null)
protected function fillParserOutput( Title $title, $revId,
ParserOptions $options, $generateHtml, ParserOutput &$output
) {
- global $wgParser;
-
$stackTrace = ( new RuntimeException() )->getTraceAsString();
if ( $this->previousParseStackTrace ) {
// NOTE: there may be legitimate changes to re-parse the same WikiText content,
$this->previousParseStackTrace = $stackTrace;
list( $redir, $text ) = $this->getRedirectTargetAndText();
- $output = $wgParser->parse( $text, $title, $options, true, true, $revId );
+ $output = MediaWikiServices::getInstance()->getParser()
+ ->parse( $text, $title, $options, true, true, $revId );
// Add redirect indicator at the top
if ( $redir ) {