Repository navigation
Fix mw.message plain() to substitute $N params in raw messages - #433
Merged
kristian-clausal merged 1 commit intoOct 6, 2026
Merged
Conversation
mw.message.newRawMessage() stores the message text in data.rawMessage and its params in data.params, but plain() returned data.keys, which newRawMessage never sets. So plain() returned nil for raw messages, and modules that build a message from a raw string plus params emitted the unsubstituted text with literal $1, $2 placeholders. This affected Module:Citation/CS1, whose substitute() falls back to the raw string when a message is falsy. Match the MediaWiki Messages API: substitute $N (one-based, multi-digit supported) with the corresponding param and leave unknown placeholders untouched. Keep returning data.keys for key-based messages as before.
Collaborator
|
Thank you for noticing and taking care of this, this looks excellent to me! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
mw.message.newRawMessage()stores the message text indata.rawMessageand its params indata.params, butplain()returneddata.keys, whichnewRawMessage()never sets. Soplain()returnednilfor raw messages, and any module that builds a message from a raw string plus params emitted the unsubstituted text with literal$1,$2placeholders.This shows up with
Module:Citation/CS1. Itssubstitute()helper treats a falsy message result as "no replacement" and silently falls back to the raw string, so warnings came out as e.g.... {{$1}}/$2 ...instead of the intended... [[Template:...]] ....The fix follows the MediaWiki Messages API: substitute
$N(one-based, multi-digit supported) with the corresponding param, and leave unknown placeholders untouched. Key-based messages keep the previousdata.keysbehavior.Added two tests in
tests/test_lua.py, covering basic substitution and multi-digit$N.