Page MenuHomePhabricator

{{{realName|{{{name}}}}}} does not work
Open, NormalPublic

Description

If I put {{{realName|{{{name}}}}}} into the welcome template the real name gets show if it is provided. However the user name {{{name}}} is omitted if no real name {{{realName}}} was provided on registration. REL1_22, MW 1.22.15, PHP 5.4.32

Event Timeline

Kghbln created this task.Jan 22 2015, 12:39 PM
Kghbln updated the task description. (Show Details)
Kghbln raised the priority of this task from to Needs Triage.
Kghbln added a subscriber: Kghbln.
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJan 22 2015, 12:39 PM
Kghbln updated the task description. (Show Details)Jan 22 2015, 12:54 PM
Kghbln set Security to None.

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.

Krinkle triaged this task as Normal priority.Jan 22 2015, 7:05 PM
Krinkle added a project: good first bug.

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.

AYUSH added a subscriber: AYUSH.Mar 27 2015, 12:57 PM
Restricted Application added a subscriber: TerraCodes. · View Herald TranscriptSep 24 2017, 1:35 PM
Krinkle removed a subscriber: Krinkle.Sep 25 2017, 5:14 PM
Shogil claimed this task.Wed, Apr 10, 4:56 AM
Restricted Application added a subscriber: Liuxinyu970226. · View Herald TranscriptWed, Apr 10, 4:56 AM
Shogil removed Shogil as the assignee of this task.Wed, Apr 10, 8:36 AM
Shogil added a subscriber: Shogil.
Shogil claimed this task.Wed, Apr 10, 8:39 AM