Don't wrap output added by OutputPage::addWikiText*()
authorC. Scott Ananian <cscott@cscott.net>
Tue, 25 Sep 2018 13:06:12 +0000 (09:06 -0400)
committerC. Scott Ananian <cscott@cscott.net>
Tue, 25 Sep 2018 18:43:20 +0000 (14:43 -0400)
commit300b91a1eccecb5f9c4e36126222edfddb33474b
tree78f2d23a8ccb253b7d2d04fd552c1f03e14837e9
parent787a647026958483f4b5616141ecc1ca5a47b8e8
Don't wrap output added by OutputPage::addWikiText*()

There are three methods affected: `OutputPage::addWikiTextTidy()`,
`OutputPage::addWikiTextTitleTidy()`, and
`OutputPage::addWikiTextWithTitle()`.

There's a special case in Parser.php which adds the wrapper class from
ParserOptions to the ParserOutput only if "interface mode" is off; the
affected methods default to adding output in "content language" mode
(not "interface language" mode), but they seem to be used for
"interface messages in the content language" (rare) and so should also
be unwrapped.  This would make all the `OutputPage::addWikiText*()`
methods consistent.

The `OutputPage::addWikiTextTidy()` method is only used once in the WMF
repositories, where it is used to insert an interface message in the
content language:

https://gerrit.wikimedia.org/g/mediawiki/extensions/ProofreadPage/+/91cd2a928f53e12f7c41bc59f1085b5415632511/SpecialProofreadPages.php#40

The `OutputPage::addWikiTextWithTitle()` method is used by no one:

https://codesearch.wmflabs.org/search/?q=addWikiTextWithTitle%5C(

The `OutputPage::addWikiTextTitleTidy()` method is used only in core:

https://gerrit.wikimedia.org/g/mediawiki/core/+/3888c001a1dbc04f1fd6bb51328b1cb1296c02f6/includes/EditPage.php#2669

It seems clear that the output in this case is intended to be
unwrapped as well (the codepath adds its own explicit wrapper).

Ia58910164baaca608cea3b24333b7d13ed773339 will add additional
documentation to clarify the distinction between the different
OutputPage::addWikiText*() methods, but I felt it safer to make
this particular change first as a standalone patch, just in case
it had unexpected side effects or merited further discussion.

Change-Id: I3e5b598d358819191562b56d40ebf1cb6f3cda41
includes/OutputPage.php
tests/phpunit/includes/OutputPageTest.php