Merge "Deprecate $wgParserConf"

This commit is contained in:
jenkins-bot 2020-04-16 20:32:36 +00:00 committed by Gerrit Code Review
commit b75d059690
6 changed files with 19 additions and 9 deletions

View file

@ -85,6 +85,9 @@ For notes on 1.34.x and older releases, see HISTORY.
unchanged for revisions that only contain the main slot. The --schema-version
option can be used with the dumpBackup.php script to set the dump format.
(T238921)
* $wgParserConf - This configuration is now deprecated. It has been
effectively constant since 2008, and is ignored by core code.
Configure the ParserFactory service in order to customize the Parser used.
* …
==== Removed configuration ====

View file

@ -4465,6 +4465,9 @@ $wgInvalidRedirectTargets = [ 'Filepath', 'Mypage', 'Mytalk', 'Redirect' ];
* the contents of this variable will be out-of-date. The variable can only be
* changed during LocalSettings.php, in particular, it can't be changed during
* an extension setup function.
* @deprecated since 1.35. This has been effectively a constant for a long
* time. Configuring the ParserFactory service is the modern way to tweak
* the default parser.
*/
$wgParserConf = [
'class' => Parser::class,

View file

@ -731,6 +731,10 @@ return [
'ParserFactory' => function ( MediaWikiServices $services ) : ParserFactory {
$options = new ServiceOptions( Parser::CONSTRUCTOR_OPTIONS,
// 'class'
// Note that this value is ignored by ParserFactory and is always
// Parser::class for legacy reasons; we'll introduce a new
// mechanism for selecting an alternate parser in the future
// (T236809)
$services->getMainConfig()->get( 'ParserConf' ),
// Make sure to have defaults in case someone overrode ParserConf with something silly
[ 'class' => Parser::class ],

View file

@ -350,7 +350,7 @@ class Parser {
* @since 1.35
*/
public const CONSTRUCTOR_OPTIONS = [
// See $wgParserConf documentation
// Deprecated and unused; from $wgParserConf
'class',
// See documentation for the corresponding config options
'ArticlePath',

View file

@ -58,9 +58,10 @@ class DumpRenderer extends Maintenance {
$this->startTime = microtime( true );
if ( $this->hasOption( 'parser' ) ) {
global $wgParserConf;
$wgParserConf['class'] = $this->getOption( 'parser' );
$this->prefix .= "-{$wgParserConf['class']}";
$this->prefix .= "-{$this->getOption( 'parser' )}";
// T236809: We'll need to provide an alternate ParserFactory
// service to make this work.
$this->fatalError( 'Parser class configuration temporarily disabled.' );
}
$source = new ImportStreamSource( $this->getStdin() );

View file

@ -791,12 +791,9 @@ class ParserTestRunner {
* @return Parser
*/
public function getParser() {
global $wgParserConf;
$class = $wgParserConf['class'];
$parser = new $class( $wgParserConf );
$parserFactory = MediaWikiServices::getInstance()->getParserFactory();
$parser = $parserFactory->create(); // A fresh parser object.
ParserTestParserHook::setup( $parser );
return $parser;
}
@ -1140,6 +1137,7 @@ class ParserTestRunner {
Hooks::run( 'ParserTestGlobals', [ &$setup ] );
// Set content language. This invalidates the magic word cache and title services
// In addition the ParserFactory needs to be recreated as well.
$lang = MediaWikiServices::getInstance()->getLanguageFactory()->getLanguage( $langCode );
$lang->resetNamespaces();
$setup['wgContLang'] = $lang;
@ -1158,6 +1156,7 @@ class ParserTestRunner {
$reset = function () {
MediaWikiServices::getInstance()->resetServiceForTesting( 'MagicWordFactory' );
$this->resetTitleServices();
MediaWikiServices::getInstance()->resetServiceForTesting( 'ParserFactory' );
};
$setup[] = $reset;
$teardown[] = $reset;