-
Notifications
You must be signed in to change notification settings - Fork 208
PHPC-1411: Accept 64-bit integers for wTimeoutMS #1042
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
Conversation
Updated now that CDRIVER-3396 has been fixed. Contains the single commit from #1060 until that PR is merged. |
9d9dd51
to
f1f6cb1
Compare
dabe6a4
to
a9861a0
Compare
@jmikola: updated the logic again after our discussion yesterday. I've added a few new symbols:
The |
src/MongoDB/WriteConcern.c
Outdated
@@ -358,7 +368,7 @@ static HashTable* php_phongo_write_concern_get_properties_hash(zval* object, boo | |||
if (wtimeout != 0) { | |||
zval z_wtimeout; | |||
|
|||
ZVAL_LONG(&z_wtimeout, wtimeout); | |||
php_phongo_int64_to_zval(wtimeout, &z_wtimeout, is_bson TSRMLS_CC); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to always call php_phongo_int64_to_zval
here? php_phongo_write_concern_get_properties_hash
is called from three places:
get_debug_info
handlerget_properties
handlerbsonSerialize()
method
We know that bsonSerialize()
needs to conditionally use an Int64 object if the value exceeds the range of a 32-bit integer. If wtimeout
is within the range of a 32-bit integer, we can add it as an integer primitive.
The debug and properties handlers need not ensure compatibility between 32-bit and 64-bit architectures (unlike serialize()
, so I think they'd do well to also encode as an integer whenever possible and only fall back to a string on a 32-bit architecture when wtimeout
exceeds the range of a 32-bit integer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea was to always export as a string, since code might be serialised using var_export
on a 64-bit architecture and then read on a 32-bit architecture. In this case, we'd export as an int, but then be unable to read it. That was the main reason for always treating it as if we were on a 32-bit platform.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I wasn't too concerned about var_export
being used across platforms since it actually produces code that the user would probably manually edit (unless they're using eval()
). I was thinking of serialize()
as the more likely way folks might transport between platforms.
In my experience (from GitHub issues), most people using var_export
are doing so as an alternative to var_dump
and didn't actually rely on __set_state()
to rebuild an object.
I'm happy to have var_export
produce a string as needed, though.
Note: I will follow up with a PR against your branch when I get a chance. |
Thanks Jeremy! I've added your changes to this PR, so I think this is good for another review 🎉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One suggestion for something I overlooked in the PR to your branch.
LGTM!
For serialization, 64-bit wtimeout values will always be encoded as strings for portability. Debug output and bsonSerialize() can always use integers on 64-bit platforms and can fall back to strings and Int64 objects on 32-bit platforms, respectively.
https://jira.mongodb.org/browse/PHPC-1411