-
Notifications
You must be signed in to change notification settings - Fork 15.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
php: Fix formatting of Duration #6155
php: Fix formatting of Duration #6155
Conversation
c8bfcae
to
8a8dc23
Compare
@TeBoring Mergeable is telling me to include a language label but I don't quite understand how I'm supposed to do that. And does this PR belong to the "Various bug fixes" banner that's already in the CHANGES.txt? |
I'm having the same problem with my pull request too, so you're not alone. I submitted my pull request to one of the docs in protobuf, and it initially passed all "tests," but then it stopped and said I'm missing labels for languages and a ton of other things even though (1) there's no option for that, and (2) the doc I submitted a pull for contains multiple languages so selecting a single language is impossible. |
We have conformance test at https://github.com/protocolbuffers/protobuf/blob/master/conformance/binary_json_conformance_suite.cc |
To run conformance test, |
8a8dc23
to
92ce1ed
Compare
@TeBoring Thanks for your advice. I tried running the conformance tests by checking out protobuf and running:
but the runner gets stuck soon. The cause is a "Undefined offset: 123" notice in the stderr output.
getValueByNumber is called in two different places and both assume that the return value is nullable, even though it's written in such a way that implies that $number is always a valid key.I think I'm going to fix this as part of this PR as I'm unable to run the conformance tests otherwise. |
92ce1ed
to
482c31e
Compare
@TeBoring This PR fixes the I don't understand why it doesn't fix e.g. the
Even though there's supposed to be no trailing zeroes when being formatted: protobuf/src/google/protobuf/duration.proto Lines 98 to 100 in b4f1937
Do you know why that's the case? Is the duration.proto description incorrect?
|
syntax error, unexpected '?' in /tmp/protobuf/protobuf/php/src/Google/Protobuf/Internal/EnumDescriptor.php on line 42 |
In our spec for serialization, we require nanosec has 0/3/6/9 digits precision. |
@TeBoring Ah I used the null-coalescing operator - I'm very sorry. 😔 |
482c31e
to
a740378
Compare
This fixes: * Missing nanoseconds. The nanoseconds where divided as a float and implicitly converted to a string before being passed to bcadd. This can result in a float formatted in scientific/exponential notation, which bcmath doesn't understand. * Durations are supposed to be formatted without trailing zeroes.
a740378
to
f654435
Compare
@TeBoring I've updated this PR finally. This PR also fixes the 0/3/6/9 digit formatting. If you dislike that I can open a separate PR for that. |
@TeBoring (Just in case you missed it...) I think you can trigger kokoro again.
|
Thanks for the fix! |
This fixes the following issues for php's native Duration class:
bcadd
(Most bcmath functions accept their parameters as strings!). This can result in a float formatted in scientific/exponential notation, which bcmath doesn't understand.E.g. a Duration instance with 123s and 456ns can previously result in an invocation like
sprintf
seems like a far simpler solution to me.I've added a simple call to
rtrim
for this.