Last modified: 2012-04-16 09:15:44 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T30582, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 28582 - {{formatnum:}} formats all numbers in the input if the input itself is not numerical, even numbers inside links
{{formatnum:}} formats all numbers in the input if the input itself is not nu...
Status: NEW
Product: MediaWiki
Classification: Unclassified
Templates (Other open bugs)
unspecified
All All
: Low normal (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-04-17 13:11 UTC by Robert Ribnitz
Modified: 2012-04-16 09:15 UTC (History)
4 users (show)

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


Attachments

Description Robert Ribnitz 2011-04-17 13:11:20 UTC
The {{fact}} template on Simple English wikipedia will add a category "Articles with unsourced statements since {{date}}". date is commonly set to values like "February 2009". The problem with that is that if the facr template is used inside another (eg. infobox) that uses number formatting, the year of the "date" will also be formatted, before it is passed to the template fact. We end up with a caegory: "Articles with unsourced statements since February 2,009", instead of the expected "Articles with unsourced statements since February 2009". What is probably needed is a way to tell the system that arguments to inner templates should not be parsed (and treated like "Text").

http://simple.wikipedia.org/w/index.php?title=Skopje&oldid=2642872 gives an example of this. Fact is used inside an {{Infobox Settlement}} which formats numbers like population in the settlement and metro area.
Comment 1 Roan Kattouw 2011-04-17 13:15:29 UTC
The best description I can give of what's actually going on here is that {{formatnum:750000 [[Category:Articles with unsourced statements since January 2009]]}} formats both the number and the year in the category tag, resulting in "750,000 [[Category:Articles with unsourced statements since January 2,009]]". I've changed the bug summary accordingly, but I'm not entirely sure that this is a bug. Maybe it's reasonable to expect formatnum to leave things in link brackets alone.
Comment 2 Robert Ribnitz 2011-04-17 13:37:26 UTC
Yes, that is basically what is occurring. Making formatnum ignore things in link brackets (perhaps guided with an additional parameter) would probably be a suitable workaround.
Comment 3 Niklas Laxström 2011-04-17 13:42:40 UTC
I think the current behavior is acceptable given that only numbers are valid input for formatnum.
Comment 4 Robert Ribnitz 2011-04-18 09:32:15 UTC
While this is certainly true, it does not solve the problem. The problem is that the fact-template can also be added to "numbers", or "cells with formatted numbers" (in other templates). We therefore either need a replacement that can be used in such cases, or we need to fix the behaviour to be able to generate correct (ie. unformatted) references/categories.
Comment 5 Brion Vibber 2011-04-20 18:10:25 UTC
It sounds like what you want to end up with is this:

{{formatnum:750000}} [[Category:Articles with unsourced statements since January 2009]]

instead of this:

{{formatnum:750000 [[Category:Articles with unsourced statements since January 2009]]}}

The use of {{formatnum}} where it is on those templates sounds like it's simply not leaving room for additional annotations -- the entire field is expected to be a number. This then fails to create the expected result when you pass in something other than a number -- such as a number and some other text which also includes numbers. It would be similarly broken if this wasn't a link and just said "{{formatnum:750000 as of year 2010 US Census}}".

Either the template should add a second parameter for annotations, or only the numbers should be given the number format wrapper, eg by applying it on the number in the template invocation.
Comment 6 Gadget850 2011-10-16 12:20:38 UTC
See Bug 21054.

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


Navigation
Links