If I put {{{realName|{{{name}}}}}} into the welcome template, the real name gets show if it is provided. However, the username {{{name}}} is omitted if no real name {{{realName}}} was provided on registration. REL1_22, MW 1.22.15, PHP 5.4.32
Description
Details
| Subject | Author | Repo | Branch | Lines +/- | |
|---|---|---|---|---|---|
| substString: omit realName param when empty | Neriah | mediawiki/extensions/NewUserMessage | master | +8 -4 |
Event Timeline
In MediaWiki core, the realName value defaults to an empty string (unbeknownst to NewUserMessage).
In NewUserMessage, the realName parameter is unconditionally set. If you wish to conditionally use it based on whether it has a value and fallback that way, you'd have to use something like the ParserFunctions #if magic word. Like: {{#if: {{{realName|}}} | {{{realName}}} | {{{name}}} }}.
Alternatively, the NewUserMessage extension could check each parameter and build up the template transclusion parameters based on the presence and thus allow {{{realName| {{{name}}} }}} to work. However that might be unconventional and inconsistent with other templates, and also break compatibility with existing wikis that assume the parameter to be present. The problem being that if a template uses {{{realName}}} somewhere, it would result in the literal code {{{realName}}} to be displayed to a user, whereas now it falls back to an empty string.
We can announce a backwards-incompatible change that requires users to add a pipe (|) to ensure it falls back.
Thank you very much for your insight. Well I guess I could/should have thought of using the #if parser function myself. So yes, this solution works perfect when the ParserFunctions extension is present.
I think it will still be nice to have this working out of the box as it used to in the past, ensuring fallback. The {{{realName| {{{name}}} }}} syntax was afaik the recommended way for this extension from its beginning.
Since most wikis have the ParserFunctions extension installed and if not since it is very easy to install it, this will probably not be a front-burner issue.
Removing task assignee due to inactivity, as this open task has been assigned for more than two years (see emails sent to assignee on May26 and Jun17, and T270544). Please assign this task to yourself again if you still realistically [plan to] work on this task - it would be very welcome!
(See https://www.mediawiki.org/wiki/Bug_management/Assignee_cleanup for tips how to best manage your individual work in Phabricator.)
Change #1301750 had a related patch set uploaded (by Neriah; author: Neriah):
[mediawiki/extensions/NewUserMessage@master] substString: omit realName param when empty