Page MenuHomePhabricator

Cannot easily edit negative quantities after saving / Wikibase can’t parse − (U+2212 MINUS SIGN) for decimal quantities
Closed, ResolvedPublic8 Estimated Story Points

Description

As an editor, I want to be able to edit negative quantity amounts easily (on any entity that has a decimal value to it), in order to fix them if they’re wrong.

Problem:
Wikibase uses the character − (U+2212 MINUS SIGN) to format negative quantities (instead of - U+002D HYPHEN-MINUS), but does not recognize this character when parsing quantities (at least in English). This means that after entering a negative quantity as e.g. “-10”, trying to edit it again presents it as “−10”, and changing it to e.g. “−100” doesn’t permit saving (the “publish” button is disabled) – you have to manually change the minus sign and save “-100”.

Example:
Can be tested easily enough on the sandbox item.

Screenshots/mockups:






Acceptance criteria:

  • Wikibase parses − as a negative sign for quantities.

Open questions:

  • Are any other characters affected? Keeping in mind that quantity formatting is localized.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptMon, Feb 8, 11:47 AM
Lucas_Werkmeister_WMDE renamed this task from Cannot easily edit decimal quantities after saving / Wikibase can’t parse − (U+2212 MINUS SIGN) for decimal quantities to Cannot easily edit negative quantities after saving / Wikibase can’t parse − (U+2212 MINUS SIGN) for decimal quantities.Wed, Feb 10, 1:40 PM

Task inspection hints:

  • we presume that we will probably need to change the parser to allow the minus sign
  • as an entry point it might make sense to start from the wbparsevalue API action
  • also look at extensions/Wikibase/vendor/data-values/number/src/ValueParsers/DecimalParser.php, normalizeDecimal()

Change 665357 had a related patch set uploaded (by Tonina Zhelyazkova; owner: Tonina Zhelyazkova):
[mediawiki/extensions/Wikibase@master] Allow minus sign (alongside hyphen-minus) to be parsed for quantities

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

@Lydia_Pintscher, judging by the existing code, there were some efforts to support “heavy plus sign” and “heavy minus sign” before.
Should we also include those two signs along the fix for this ticket?

@Lydia_Pintscher, judging by the existing code, there were some efforts to support “heavy plus sign” and “heavy minus sign” before.
Should we also include those two signs along the fix for this ticket?

I would say no.

In general I'm a bit worried how this bug comes about. Because this is such an obvious issue that I'm really not sure how this wasn't brought up by the editors before unless a recent change has caused it similar to what happened in T268456. Did anyone look a bit deeper there already?

Did anyone look a bit deeper there already?

There as in T268456? I don't know for sure but by the looks of it I'd say no. Seems like the task was concluded with Lucas's solution.

I guess the thing that changed is that MediaWiki started formatting negative numbers with the “long minus”: $wgLang->formatNum( '-1' ) is "-1" on FactGrid (1.35.1) but "−1" locally. MediaWiki can also parse the “long minus” as part of numbers, but we have some of our own parsing code in front of MediaWiki, and that’s what we need to update now.

Change 665357 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Allow minus sign (alongside hyphen-minus) to be parsed for quantities

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

I guess the thing that changed is that MediaWiki started formatting negative numbers with the “long minus”: $wgLang->formatNum( '-1' ) is "-1" on FactGrid (1.35.1) but "−1" locally. MediaWiki can also parse the “long minus” as part of numbers, but we have some of our own parsing code in front of MediaWiki, and that’s what we need to update now.

Thanks. That was what I was after but didn't properly express :P
That leaves me with the question: Are we exposing things correctly in linked data interface and action API? From a quick check yes but making double sure.

That leaves me with the question: Are we exposing things correctly in linked data interface and action API? From a quick check yes but making double sure.

As far as I can tell, yes.

amy_rc added a subscriber: amy_rc.Wed, Feb 24, 2:53 PM

tested and works!!

amy_rc closed this task as Resolved.Thu, Feb 25, 9:31 AM