RCFilters: Export i18n messages as a config var instead of inline script
authorRoan Kattouw <roan.kattouw@gmail.com>
Thu, 9 Aug 2018 01:31:04 +0000 (18:31 -0700)
committerRoan Kattouw <roan.kattouw@gmail.com>
Thu, 9 Aug 2018 01:31:04 +0000 (18:31 -0700)
commit2dd6342b646fd62420f79d697a4e608360dd6871
treef3b4f96aafa078d65beff2fa00735dfec3b49c84
parent97c35356592bd6dc1ee7fade4131d5e8a4524e2a
RCFilters: Export i18n messages as a config var instead of inline script

We used to generate an inline script tag with an mw.messages.set(...)
call to export these i18n messages, but there are no guarantees that
this script tag will run before mw.rcfilters.init does and tries to
access these messages. This race condition doesn't seem to be happening
in practice right now, but dec800968eb makes it more probable.

Instead, export the messages object as a config var in mw.config, and
import it into mw.messages at the start of mw.rcfilters.init. This just
moves the blob from one inline script tag to another, but mw.config is
guaranteed to be populated before any modules execute.

Longer term, we should move these messages, as well as the filter
definitions, to a ResourceLoader module rather than embedding them in
every page view. I filed T201574 for that.

Bug: T192623
Change-Id: I2d58f55701b28876a6491432cee0fc56f97ff00b
includes/specialpage/ChangesListSpecialPage.php
resources/src/mediawiki.rcfilters/mw.rcfilters.init.js