Page MenuHomePhabricator

#default without value causes switch to default to last argument
Closed, ResolvedPublic

Description

Author: fpahl

Description:
Example: {{#switch:a|b=c|#default|e=f|g=h}}

This currently expands to h. It would make sense for it to either ignore the #default key without a value (i.e. treat the value as empty) or to treat it like any other key without a value, i.e. fall through and return f. But I don't see any rationale for returning the last value.


Version: unspecified
Severity: minor

Details

Reference
bz23192

Event Timeline

bzimport raised the priority of this task from to Low.Nov 21 2014, 11:05 PM
bzimport added a project: ParserFunctions.
bzimport set Reference to bz23192.
bzimport added a subscriber: Unknown Object (MLST).

fpahl wrote:

A further detail:

Usually, if more than one #default is provided, the last one is used (in contrast to other keys, where the first instance is used): {{#switch:a|b=c|#default=x|#default=y|e=f|g=h}} yields y.

However, a #default without a value causes the last value to be used (see above) even if it is followed by a proper #default with value: {{#switch:a|b=c|#default|#default=y|e=f|g=h}} yields h, not y.

Change 87643 had a related patch set uploaded by Nemo bis:
Fix #switch #default to match next (not last) named parameter.

https://gerrit.wikimedia.org/r/87643

Change 87643 merged by jenkins-bot:
Fix #switch #default to match next (not last) named parameter.

https://gerrit.wikimedia.org/r/87643

This should be deployed to WMF wikis with 1.24wmf14, see https://www.mediawiki.org/wiki/MediaWiki_1.24/Roadmap for the schedule.