Send quantities as strings
Needs RevisionPublic

Authored by matej_suchanek on Dec 9 2017, 5:11 PM.

Details

Reviewers
Magnus
Lucas_Werkmeister_WMDE
thiemowmde
Patch without arc
git checkout -b D911 && curl -L https://phabricator.wikimedia.org/D911?download=true | git apply
Summary

What happens:

What we want:

When I modified the POST request in the console and wrapped the number in quotes, it produced the second diff.

Diff Detail

Lint
Lint Skipped
Unit
Unit Tests Skipped
matej_suchanek created this revision.Dec 9 2017, 5:11 PM

LGTM. I’ll do “accept revision” and hope that doesn’t merge the change yet, because I think that should be left to Magnus :)

This revision is now accepted and ready to land.Dec 9 2017, 6:24 PM
thiemowmde requested changes to this revision.Dec 12 2017, 4:42 PM
thiemowmde added a subscriber: thiemowmde.

A straight string conversion will not work in cases like 0.000000002. PHP will turn this into 2.0E-9, and the Wikibase deserializers will not accept this. See https://github.com/DataValues/Number/pull/115 for more test cases.

This revision now requires changes to proceed.Dec 12 2017, 4:42 PM

Hm, so this is trivial for the quantity amount (and whole boundless value) but not for the bounds since I need to work with the floats.

What do you suggest? I have honestly no idea how to fix this (except for using the code from your patch). Floats are scary anyway...

As this is my first patch accept in Differential, how do I merge this here? No "merge" button that I can see on this page. Probably not "commandeer", whatever that is?

@thiemowmde will something simple like sprintf( '%.16f', $value ) work? (Importing the DataValues library would probably be the proper solution, but I’m not sure how easy this is, and it would be nice to get some version of this change merged soon.)