Page MenuHomePhabricator

Pass empty parameters to parser functions
Closed, DeclinedPublic

Description

Author: fernandoacorreia

Description:
If a template includes a parser function passing parameters and some of these
parameters are empty, the parameter reference {{{n}}} is passed to the parser
function. An empty string should be passed.

For instance, the template includes:

{{#swf:{{{1}}}|{{{2}}}|{{{3}}}|{{{4}}}}}

The parser function declaration is:

function wfPlaySwfParserFunctionRender( &$parser, $filename = '', $filetitle =
'', $width='', $height='' )

If a template is used with only two parameters, $width and $heigth receive
"{{{3}}}" and "{{{4}}}" in the parser function. They should be empty.


Version: 1.8.x
Severity: normal
OS: Windows XP
Platform: PC

Details

Reference
bz8320

Event Timeline

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

ayg wrote:

Um, isn't this what parameter defaults are for? {{{1|}}} will return empty if 1
is undefined.

fernandoacorreia wrote:

You may be right. But I think it's odd that an extension should receive such a
string. It seems like the template parameter syntax should be resolved within
the template, not exposed.

It's no more odd than specifying that a function should receive an object reference
(eg &$parser) rather than a scalar value (eg $filename).

In both cases you have to make sure that you pass the correct kind of parameter
otherwise your code is not going to work.

The point here is that the wiki-text "{{{3}}}" is defined to be the value of anonymous
parameter #3 unless that parameter is blank in which case the default value
is "{{{3}}}". Changing that definition would breaking existing usage and is unlikely
to happen. Having your function validate its input would probably be your best bet.

fernandoacorreia wrote:

OK, thanks.