Manual:$wgParser
From Linux Web Expert
File:OOjs UI icon alert-destructive.svg | <translate> This feature was removed completely in version <tvar name=ver>1.39.0</tvar>.</translate> |
<translate> [[<tvar|1>Special:MyLanguage/Manual:Global object variables</>|Global object]]:</translate> $wgParser | |
---|---|
Parser object | |
<translate> Deprecated in:</translate> | 1.32.0 |
<translate> Removed in:</translate> | 1.39.0 |
<translate> Class:</translate> | Parser |
<translate> Located in:</translate> | Parser.php |
Description
The Parser object is responsible for parsing the tags and wikitext contained in wiki pages. Parser extensions hooks are also registered in the Parser object.
Use
MediaWikiServices::getInstance()->getParser()
instead (phab:T160811).Mode of Operation
$wgParser
is called in includes/Setup.php
with the following code:
$wgParser = new StubObject( 'wgParser', $wgParserConf['class'], array( $wgParserConf ) );
StubObject is defined in includes/StubObject.php
.
wgParserConf is defined in includes/DefaultSettings.php
with the following code:
$wgParserConf = array('class' => 'Parser',);
Replacement
<td class="mw-version-versionbox" title="<translate nowrap> The latest stable version is <tvar name=1>1.41</tvar></translate>"><translate> ≥</translate> 1.32
<translate> MediaWiki version:</translate> |
New code should use dependency injection instead.
The parser is now available in the service locator under the Parser
service.
Existing code that has not yet been changed to use dependency injection can call the service locator directly:
public function render() {
$parser = \MediaWiki\MediaWikiServices::getInstance()->getParser();
$text = $parser->parse(
...
)->getText();
}