Page MenuHomePhabricator

Use ParserOptions::isMessage() instead of ParserOptions::getInterfaceMessage() in DiscussionTools
Closed, ResolvedPublic

Description

In theory, ParserOptions::isMessage() is an improved version of ParserOptions::getInterfaceMessage(), allowing us to detect when a message is being parsed in any language, not just user interface language.

In practice, trying to make this change caused T395034: Incorrect and doubled empty talk page onboard messages on every talk page of Chinese Wikipedia.

To do:

  1. Add a regression test for that bug
  2. Find out why that happened and fix the underlying problem
  3. Reapply https://gerrit.wikimedia.org/r/c/mediawiki/extensions/DiscussionTools/+/1143704

Event Timeline

  1. Find out why that happened

rMW includes/Output/OutputPage.php:2050 (at d04dd77179d5) suspiciously sets only interfaceMessage, not message. And surprise, surprise, it does get called (indirectly) by rMW includes/page/Article.php:1292 (at d04dd77179d5).

and fix the underlying problem

This is a good question.

  • Should OutputPage::internalParserOptions() call both methods? It sounds like it’s none of its business.
  • Should ParserOptions::setInterfaceMessage(true) imply ParserOptions::setIsMessage(true) (of course without false implying false)? Sounds better in terms of responsibilities, but it may break other code.
  • Something else?

rMW includes/Output/OutputPage.php:2050 (at d04dd77179d5) suspiciously sets only interfaceMessage, not message. And surprise, surprise, it does get called (indirectly) by rMW includes/page/Article.php:1292 (at d04dd77179d5).

(…)

  • Should OutputPage::internalParserOptions() call both methods? It sounds like it’s none of its business.
  • Should ParserOptions::setInterfaceMessage(true) imply ParserOptions::setIsMessage(true) (of course without false implying false)? Sounds better in terms of responsibilities, but it may break other code.
  • Something else?

Right. So anything that uses OutputPage::wrapWikiMsg (and it's a fairly common method) is going to have the interfaceMessage option set, but not the message option.

OutputPage::internalParserOptions is probably used for non-message wikitext parsing too, so we can't change it there, but we should probably change it for wrapWikiMsg, somehow.

We should probably review all uses of ParserOptions::setInterfaceMessage (https://codesearch.wmcloud.org/search/?q=setInterfaceMessage\b) and consider if they should use setIsMessage too. This would have caught T395023 too. I'm not sure if it would be good to make it implied.

Change #1152123 had a related patch set uploaded (by Bartosz Dziewoński; author: Bartosz Dziewoński):

[mediawiki/core@master] OutputPage: Use ParserOptions::setIsMessage() in wrapWikiMsg()

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

Change #1152125 had a related patch set uploaded (by Bartosz Dziewoński; author: Bartosz Dziewoński):

[mediawiki/extensions/DiscussionTools@master] Revert^2 "In ParserAfterTidy use the new ParserOptions::isMessage"

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

Change #1152140 had a related patch set uploaded (by Bartosz Dziewoński; author: Bartosz Dziewoński):

[mediawiki/extensions/DiscussionTools@master] Add tests for empty state hooks

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

Change #1152123 merged by jenkins-bot:

[mediawiki/core@master] OutputPage: Use ParserOptions::setIsMessage() in wrapWikiMsg()

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

Change #1152125 merged by jenkins-bot:

[mediawiki/extensions/DiscussionTools@master] Revert^2 "In ParserAfterTidy use the new ParserOptions::isMessage"

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

Change #1152140 merged by jenkins-bot:

[mediawiki/extensions/DiscussionTools@master] Add tests for empty state hooks

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