Page MenuHomePhabricator

ParserIntegrationTest doesn't reload ParserFactory and always test parser with default options
Closed, ResolvedPublic

Description

Motivation

There're many places in the code (particularly) in extensions/intersection where the parser is created via direct access to MediaWikiServices:

MediaWikiServices::instance()->getParserFactory()->create();

As far as parserFactory is a singleton it always creates the Parser with the options were actual when ParserFactory initialized.

So the tests, particularly ParserIntegrationTest run with settings provided from LocalSetting, not test settings,

Expected result:

ParserIntegrationTest should reset ParserFactory service on setUp so that it's created with the settings provided by the test.

Additional info:

This issue blocks the paths: https://gerrit.wikimedia.org/r/c/mediawiki/extensions/intersection/+/572720
and T244055

Event Timeline

Change 584924 had a related patch set uploaded (by Peter.ovchyn; owner: Peter.ovchyn):
[mediawiki/core@master] parser: Reset ParserFactory service in ParserIntergrationTests

https://gerrit.wikimedia.org/r/584924

Peter.ovchyn renamed this task from ParserIntegrationTest doesn't reload ParserFactory what leads to side effects between to ParserIntegrationTest doesn't reload ParserFactory and always test parser with default parameters.Mar 31 2020, 6:05 PM
Peter.ovchyn updated the task description. (Show Details)
Peter.ovchyn renamed this task from ParserIntegrationTest doesn't reload ParserFactory and always test parser with default parameters to ParserIntegrationTest doesn't reload ParserFactory and always test parser with default options.Mar 31 2020, 6:07 PM
Peter.ovchyn updated the task description. (Show Details)

I don't necessarily agree that extensions should be calling MediaWikiServices::instance()->getParserFactory()->create(); All extensions should be given a $parser object in their hooks, they should be using that.

Change 589397 had a related patch set uploaded (by C. Scott Ananian; owner: C. Scott Ananian):
[mediawiki/core@master] Deprecate $wgParserConf

https://gerrit.wikimedia.org/r/589397

Change 584924 abandoned by C. Scott Ananian:
parser: Reset ParserFactory service in ParserIntergrationTests

Reason:
Done as part of I787f22ea9bf59a049b13631ba6974866a1300988 -- thanks for the pointer to this issue!

https://gerrit.wikimedia.org/r/584924

Change 589397 merged by jenkins-bot:
[mediawiki/core@master] Deprecate $wgParserConf

https://gerrit.wikimedia.org/r/589397