Page MenuHomePhabricator

Subst should work for parameters
Open, LowPublicFeature

Description

Author: bugzilla.wikimedia

Description:
Hi,

first of all, apologies if this is a duplicate report, but I haven't been able
to find a previous report for this bug.

I just noticed something slightly odd about the way templates with parameters
with default values are handled by {{subst:}} - it seems that when the
template's contents are put into the page text, parameters that are not
specified but which do have a default value are not replaced.

The effect of this can be seen with [[en:Template:Unsigned]], used at the URL
given above with '{{subst:Unsigned|Rpgaction}}', for example: observe that the
unspecified second parameter ('{{{2|}}}') is literally copied into the page text.

This does not make any real difference here, but MediaWiki should copy the
parameter's default value in this case instead.


Version: unspecified
Severity: enhancement
URL: http://en.wikipedia.org/wiki/User:Simetrical/6305

Details

Reference
bz6305

Event Timeline

bzimport raised the priority of this task from to Low.Nov 21 2014, 9:15 PM
bzimport set Reference to bz6305.
bzimport added a subscriber: Unknown Object (MLST).

achuggard wrote:

Also neither {{{<includeonly>subst:</includeonly>param|default}}} nor
{{{{{{subst|}}}param|default}}} work to solve this. (result:
{{{subst:param|default}}} in wikitext.

ayg wrote:

(In reply to comment #0)

I just noticed something slightly odd about the way templates with parameters
with default values are handled by {{subst:}} - it seems that when the
template's contents are put into the page text, parameters that are not
specified but which do have a default value are not replaced.

This request is pretty much bug 2777. Substing copies the text of the target
exactly, it doesn't subst anything that's transcluded there.

(In reply to comment #1)

Also neither {{{<includeonly>subst:</includeonly>param|default}}} nor
{{{{{{subst|}}}param|default}}} work to solve this. (result:
{{{subst:param|default}}} in wikitext.

Confirmed (look at wikitext of [[User:Simetrical/6305b]]). To clarify, "subst:"
is nonfunctional for variables, period. I'm changing the summary accordingly,
and refiling as enhancement because that isn't strictly speaking a bug.

mr.heat wrote:

I found a similar bug. Maybee it's the same. For example, I created a template called "Negative" which calculates something. The source of this template is {{<includeonly>subst:</includeonly>#expr: -{{{1}}} }} for example.

Usage: {{subst:Negative|7}}
Result: -7

Usage: {{Negative|7}}
Result: {{subst:#expr: -{{{1}}} }}

This is very strange and completely useless, obviously. The expected result is {{Negative|7}}.

mr.heat wrote:

Is this a duplicate of bug #5453?

Aklapper changed the subtype of this task from "Task" to "Feature Request".Feb 4 2022, 11:01 AM
Aklapper removed a subscriber: wikibugs-l-list.