Remove deprecated $wgParser

$wgParser, deprecated in 1.32, has been removed.

Bug: T160811
Change-Id: Iaf09d3e158e1fee8c0f541695b6d9b4233033c81
This commit is contained in:
TheSandDoctor 2019-12-29 22:58:16 -08:00 committed by Umherirrender
parent 74f9063367
commit da38639658
7 changed files with 25 additions and 31 deletions

View file

@ -259,6 +259,8 @@ because of Phabricator reports.
* In HTMLForm HTMLAutoCompleteSelectFields, the parameters 'autocomplete' and
'autocomplete-messages', which were deprecated in MediaWiki 1.29, were
removed. Instead, use 'autocomplete-data' and 'autocomplete-data-messages'.
* The global $wgParser, deprecated in 1.32, was removed. Use
MediaWikiServices::getInstance()->getParser() instead.
* ParserOutput::setText will now set the ParserOutput's text to null if
given null. Previously it did nothing if given null.
* The default value for the first argument to the ParserOutput constructor

View file

@ -56,11 +56,6 @@ $wgLang
Language object selected by user preferences.
Use IContextSource::getLanguage() instead.
$wgParser
Parser object. Parser extensions used to register their hooks here;
modern code should use the ParserFirstCallInit hook for that.
Use MediaWikiServices::getParser() instead.
$wgRequest
WebRequest object, to get request data
Use IContextSource::getRequest() instead.

View file

@ -494,7 +494,7 @@ if ( !defined( 'MW_NO_SESSION' ) && !$wgCommandLineMode ) {
}
// Explicit globals, so this works with bootstrap.php
global $wgUser, $wgLang, $wgOut, $wgParser, $wgTitle;
global $wgUser, $wgLang, $wgOut, $wgTitle;
/**
* @var User $wgUser
@ -516,14 +516,6 @@ $wgLang = new StubUserLang;
*/
$wgOut = RequestContext::getMain()->getOutput(); // BackCompat
/**
* @var Parser $wgParser
* @deprecated since 1.32, use MediaWikiServices::getInstance()->getParser() instead
*/
$wgParser = new DeprecatedGlobal( 'wgParser', static function () {
return MediaWikiServices::getInstance()->getParser();
}, '1.32' );
/**
* @var Title|null $wgTitle
*/

View file

@ -1,18 +1,25 @@
<?php
use MediaWiki\Page\PageReference;
use MediaWiki\User\UserIdentity;
/**
* A parser used during article insertion which does nothing, to avoid
* unnecessary log noise and other interference with debugging.
*/
class ParserTestMockParser {
public function preSaveTransform( $text, Title $title, User $user,
class ParserTestMockParser extends Parser {
public function __construct() {
}
public function preSaveTransform( $text, PageReference $page, UserIdentity $user,
ParserOptions $options, $clearState = true
) {
return $text;
}
public function parse(
$text, Title $title, ParserOptions $options,
$text, PageReference $page, ParserOptions $options,
$linestart = true, $clearState = true, $revid = null
) {
return new ParserOutput;

View file

@ -2576,7 +2576,18 @@ class ParserTestRunner {
// get a reference to the mock object.
if ( $this->disableSaveParse ) {
$services->getMessageCache()->getParser();
$restore = $this->executeSetupSnippets( [ 'wgParser' => new ParserTestMockParser ] );
$services->disableService( 'Parser' );
$services->disableService( 'ParserFactory' );
$services->redefineService(
'Parser',
static function () {
return new ParserTestMockParser;
}
);
$restore = static function () {
MediaWikiServices::getInstance()->resetServiceForTesting( 'Parser' );
MediaWikiServices::getInstance()->resetServiceForTesting( 'ParserFactory' );
};
} else {
$restore = false;
}

View file

@ -1312,19 +1312,7 @@ abstract class MediaWikiIntegrationTestCase extends PHPUnit\Framework\TestCase {
return true;
}
/**
* Replace legacy global $wgParser with a fresh one so it picks up any
* config changes. It's deprecated, but we still support it for now.
*/
private static function resetLegacyGlobals() {
// phpcs:ignore MediaWiki.Usage.DeprecatedGlobalVariables.Deprecated$wgParser
global $wgParser;
// We don't have to replace the parser if it wasn't unstubbed
if ( !( $wgParser instanceof StubObject ) ) {
$wgParser = new StubObject( 'wgParser', static function () {
return MediaWikiServices::getInstance()->getParser();
} );
}
ParserOptions::clearStaticCache();
}

View file

@ -61,7 +61,6 @@ class DefaultPreferencesFactoryTest extends \MediaWikiIntegrationTestCase {
$services = $this->getServiceContainer();
$this->setMwGlobals( 'wgParser', $services->getParserFactory()->create() );
$this->overrideConfigValue( MainConfigNames::DisableLangConversion, false );
$this->config = $services->getMainConfig();
}