Page MenuHomePhabricator

Function errors are rendered in the language of the user triggering parse
Closed, ResolvedPublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

  • Make sure parser cache is configured and T397946 is not affecting it ($wgArrayFunctionsEnableErrorTracking = false).
  • At Special:Preferences, set your interface language to one different from the wiki's content language. For example French on an English wiki.
  • Start an edit (does not matter whether to a new or an existing page) to a wikitext page. Add an invalid array function call that produces an error, for example {{#af_range:}} (as is).
    • For this bug to occur, the page and wiki must not have anything that may disable the parser cache for this page or fragment it by user language.
    • Purging cache or simply visiting the page after its cache has expired also works.
  • Save the edit.
  • Switch your language back (or change to another).
  • Visit the page again.

What happens?:
Function error is shown in the language of the user who has triggered the parse and subsequent cache store.

What should have happened instead?:
Function error is rendered in the page's language.

Software version (on Special:Version page; skip for WMF-hosted wikis like Wikipedia):
MediaWiki 1.43.1, using ArrayFunctions v1.16.1 (7ed1ed08b11b4388dce3eb0a4d57205b0c503046)

Other information (browser name/version, screenshots, etc.):
This is caused by the raw use of wfMessage and in MediaWiki 1.40+ can be fixed by using Parser's msg(string $key, ...$parameters) method. Older versions may require something like $msg->inLanguage( $parser->getTargetLanguage() )->page( $parser->getPage() ) (though ->page() and ->getPage() have been introduced in MediaWiki 1.37 - title() and getTitle() should be used in older versions).

Event Timeline

Change #1164496 had a related patch set uploaded (by Xxmarijnw; author: Xxmarijnw):

[mediawiki/extensions/ArrayFunctions@master] This commit fixes two separate but related issues:

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

Change #1164496 merged by jenkins-bot:

[mediawiki/extensions/ArrayFunctions@master] This commit fixes two separate but related issues:

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

Xxmarijnw claimed this task.