Page MenuHomePhabricator

Parser creation should always use factory
Open, Needs TriagePublic

Description

Historically the parser was expensive to create and accessed via a global, $wgParser. Because $wgParser was created during initialization on every request, regardless of whether parsing was needed, the constructor was made as lightweight as possible and "actual" initialization was moved to a variety of helper methods.

Modern MediaWiki uses a factory instead. We should fix the old patterns of use and (a) completely initialize the class in the constructor, and (b) ensure that everyone who uses the parser creates the object via the factory. (b) will allow us to eventually change the default parser.

Also, we should probably discourage the patterns of "resetting" an existing parser object or "cloning" it, instead just creating a new fresh parser object from the factory.

Event Timeline

cscott created this task.Oct 29 2019, 4:16 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptOct 29 2019, 4:16 PM
ssastry edited projects, added Parsoid; removed Parsoid-PHP.Nov 5 2019, 5:53 PM
ssastry removed a subscriber: Parsing-Team.
LGoto moved this task from Needs Triage to Backlog on the Parsoid board.Feb 15 2020, 12:05 AM
LGoto moved this task from Backlog to Non-Parsoid Tasks on the Parsoid board.Feb 21 2020, 5:26 PM

Change 589323 had a related patch set uploaded (by C. Scott Ananian; owner: C. Scott Ananian):
[mediawiki/core@master] Hard-deprecate direct calls to Parser::__construct()

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

Change 589346 had a related patch set uploaded (by C. Scott Ananian; owner: C. Scott Ananian):
[mediawiki/extensions/Wikibase@master] Don't invoke Parser::__construct() directly (deprecated in 1.34)

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

Change 589347 had a related patch set uploaded (by C. Scott Ananian; owner: C. Scott Ananian):
[mediawiki/extensions/GeoData@master] Don't invoke Parser::__construct() directly (deprecated in 1.34)

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

Change 589347 merged by jenkins-bot:
[mediawiki/extensions/GeoData@master] Don't invoke Parser::__construct() directly (deprecated in 1.34)

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

Change 589346 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Don't invoke Parser::__construct() directly (deprecated in 1.34)

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

Change 589396 had a related patch set uploaded (by C. Scott Ananian; owner: C. Scott Ananian):
[mediawiki/core@master] Remove ParserDiffTest

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

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 589412 had a related patch set uploaded (by C. Scott Ananian; owner: C. Scott Ananian):
[mediawiki/extensions/CiteThisPage@master] Avoid using deprecated $wgParserConf configuration variable

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

Change 589396 merged by jenkins-bot:
[mediawiki/core@master] Remove ParserDiffTest

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

Change 589412 merged by jenkins-bot:
[mediawiki/extensions/CiteThisPage@master] Avoid using deprecated $wgParserConf configuration variable

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

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

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

Change 589437 had a related patch set uploaded (by C. Scott Ananian; owner: C. Scott Ananian):
[mediawiki/core@master] WIP: Deprecate Parser::firstCallInit()

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

Change 589323 merged by jenkins-bot:
[mediawiki/core@master] Hard-deprecate direct calls to Parser::__construct()

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