Page MenuHomePhabricator

Remove 'options' arguments to ParserOutput::getText()
Open, Needs TriagePublic

Description

The way we see this working is:

  1. Every options argument to ParserOutput::getText() becomes a ParserOption. NOTE not all of these options will necessarily split the parser cache; only the ones which have been "applied" split the cache.
  2. Methods which call $parserOutput->getText() will have the ParserOption corresponding to that $parserOutput handy -- it is used in the cache lookup, so it *should* always be available, but sometimes methods don't pass it along appropriately. We will incrementally fix these APIs to ensure the ParserOptions follow the ParserOutput.
  3. (Eventually) the ParserOutput will track which parser options have already been applied to it as post-cache transformations, allowing the parser output transformation pipeline to (a) be idempotent, and (b) be cacheable at any point. So if you decide you don't want to split the parser cache for anything, you can cache the initial parser results, and handle all the rest of the parser options as post-cache transforms. If later you decide to cache the result of a particular costly intermediate transformation, or even the final transformation output streamed to the user, those will also be stored alongside the record of the transformations already done on them, so a future pass through the pipeline will perform only the "work remaining" from the set of input ParserOptions.

This ought to also avoid the need to mutate the $options array during the post cache transformation pipeline, as both WikidataPageBanner and Translate are currently doing.

See also T303615: There's no reason to split the ParserCache on wrapclass which initially proposed the opposite direction (moving a parser option into a ::getText() parameter) but that's because the parser option was splitting the cache. Step #1 above entails *not* splitting the cache for these options until/unless they are applied to the ParserOutput.

Event Timeline

Change 972047 had a related patch set uploaded (by C. Scott Ananian; author: C. Scott Ananian):

[mediawiki/core@master] [ParserOutput] Make 'enableSectionEditLinks' a ParserOption

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

Change 972048 had a related patch set uploaded (by C. Scott Ananian; author: C. Scott Ananian):

[mediawiki/core@master] [OutputPage] replace ParserOutput::getText() options with ParserOptions

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

Change 974657 had a related patch set uploaded (by C. Scott Ananian; author: C. Scott Ananian):

[mediawiki/core@master] WikiPage: remove ::suppressTOC hack

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

Change 972047 merged by jenkins-bot:

[mediawiki/core@master] [ParserOutput] Make 'enableSectionEditLinks' a ParserOption

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

Change 974657 merged by jenkins-bot:

[mediawiki/core@master] WikiPage: remove ::suppressTOC hack

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

Change #1056213 had a related patch set uploaded (by C. Scott Ananian; author: C. Scott Ananian):

[mediawiki/core@master] [OutputPage] replace ParserOutput::getText() options with ParserOptions, v2

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

Change #972048 abandoned by C. Scott Ananian:

[mediawiki/core@master] [OutputPage] replace ParserOutput::getText() options with ParserOptions

Reason:

v2 is better: Iec19f9f08a4d88ea534ffa7b24e6e01ffbba2723

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