Last modified: 2014-11-18 18:07:31 UTC

Wikimedia Bugzilla is closed!

Wikimedia has migrated from Bugzilla to Phabricator. Bug reports should be created and updated in Wikimedia Phabricator instead. Please create an account in Phabricator and add your Bugzilla email address to it.
Wikimedia Bugzilla is read-only. If you try to edit or create any bug report in Bugzilla you will be shown an intentional error message.
In order to access the Phabricator task corresponding to a Bugzilla report, just remove "static-" from its URL.
You could still run searches in Bugzilla or access your list of votes but bug reports will obviously not be up-to-date in Bugzilla.
Bug 12033 - Parameter lost when using #ifexpr in another parameter
Parameter lost when using #ifexpr in another parameter
Status: RESOLVED FIXED
Product: MediaWiki extensions
Classification: Unclassified
ParserFunctions (Other open bugs)
unspecified
All All
: Normal minor with 1 vote (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2007-11-19 10:15 UTC by Tisza Gergő
Modified: 2014-11-18 18:07 UTC (History)
2 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Tisza Gergő 2007-11-19 10:15:28 UTC
A simple expression to handle nonnumbers, negative numbers and nonnegatvie numbers differently: [[hu:User:Tgr/ifexpr]]

Here is it in a more legible format:

{{#if
  :{{#ifexpr
    :{{{1}}}
  }}
  |{{{1}}}
  |{{#ifexpr
    :{{{1}}}<0
    |{{{1}}}
    |{{{1}}}
  }}
}}

The first ifexpr only returns nonempty on error (that is, if the parameter is not a number), thus the first branch of #if is returned if not a number, the first branch of the second #ifexpr if negative, and the second branch if zero or positive. Should obviously return the parameter either way.

This works as expexted: [[hu:User vita:Tgr/ifexpr]].

Now lets try separating the is-a-number check and the is-negative check in two different templates: [[hu:Sablon:Ifnumber]] and [[hu:User:Tgr/ifexpr2]].

Check if the first parameter is a number, return the second parameter if true, the third if false:

{{#if
  :{{#ifexpr
    :{{{1}}}
  }}
  |{{{3}}}
  |{{{2}}}
}}

Check whether the first parameter is a number using the above, then check for the sign on the true branch:

{{ifnumber
  |{{{1}}}
  |{{#ifexpr
    :{{{1}}}<0
    |{{{1}}}
    |{{{1}}}
  }}
  |{{{1}}}
}}

Putting the two together, you get almost the same as the original, except that the two branches of ifnumber are swapped to make parameter order more logical.

However, this does NOT work as expected: [[hu:User vita:Tgr/ifexpr2]]

It returns "{{{3}}}" (not the third parameter, but the exact text "{{{3}}}") when the first parameter is not a number, as if the third parameter of ifnumber would have gotten lost somehow.

Ifnumber works fine in itself; I tried a similar construct with #if instead of #ifexpr, that seemed to work fine too, so I'm guessing this is a bug in #ifexpr somehow.
Comment 1 Jelte (WebBoy) 2008-08-11 20:59:07 UTC
Seems to be fixed now.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links