-
Notifications
You must be signed in to change notification settings - Fork 208
PHPC-2346: Remove deprecated BSON functions #1653
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
PHPC-2346: Remove deprecated BSON functions #1653
Conversation
27f9f43
to
9f1e2bc
Compare
Waiting on #1652 to be merged to add the upgrade note. |
/* Note: Although libbson can parse the extended JSON representation for | ||
* 64-bit integers (i.e. "$numberLong"), it currently prints them as | ||
* doubles (see: https://jira.mongodb.org/browse/CDRIVER-375). */ | ||
printf("Test %s\n", MongoDB\BSON\toJSON($bson)); | ||
hex_dump($bson); |
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.
Was asserting the parsed BSON not relevant to this test?
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 parsed BSON is printed as part of the debug data of a MongoDB\BSON\Document
instance. It prints the BSON bytes (base64 encoded for easier handling) as well as the PHP representation, so there's no need to use hex_dump
as well.
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.
Oh, I overlooked the "data" field in the debug output. 👍
int(-2147483648) | ||
object(MongoDB\BSON\Int64)#%d (%d) { | ||
["integer"]=> | ||
string(11) "-2147483648" |
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.
I assume this is related to changing toPHP(fromJSON(...))
to Document::fromJSON(...)->toPHP()
, but don't the toPHP()
functions use the same logic internally? Just curious why this might have changed.
The current output seems more correct, as the JSON input is clearly a 64-bit integer type regardless of its value.
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.
That is pretty much the only notable difference between the two implementations. Interacting with a MongoDB\BSON\Document
instance will always yield an Int64
instance for 64-bit integers, even when they fall within the 32-bit range. This will not matter in most cases as an Int64
can be coerced to an int and also used in operations as if it were an integer.
9f1e2bc
to
96eac6d
Compare
96eac6d
to
e4a1333
Compare
* v2.x: (22 commits) PHPC-2441: Remove deprecated Manager constructor options (#1719) PHPC-990: Strict type validation for boolean URI options (#1713) PHPC-2440: Remove deprecated Query constructor options (#1707) PHPC-2459: Remove support for float arg in UTCDateTime ctor (#1709) Remove obsolete test PHPC-2344 Remove SSLConnectionException (#1696) PHPC-2144 Throw a LogicException when getting info from unacknowledged write result (#1687) PHPC-2454: Remove --enable-system-ciphers configure option (#1681) PHPC-2348 Remove `WriteException` and move `getWriteResult` to `BulkWriteException` (#1685) PHPC-2417 Add UTCDateTimeInterface::toDateTimeImmutable() (#1684) PHPC-2309: Remove --with-openssl-dir configure option (#1676) PHPC-2444: Remove support for string arguments in UTCDateTime constructor (#1662) PHPC-2248: Remove Serializable implementations (#1663) Update version for 2.x branch (#1672) PHPC-1021: Remove support for ReadPreference integer modes (#1666) PHPC-2342: Remove --with-libbson and --with-libmongoc configure options (#1667) PHPC-2351: Remove CursorId class (#1664) PHPC-2140: Make tentative return types definitive (#1658) PHPC-2402: Remove range_preview constants (#1665) PHPC-2346: Remove deprecated BSON functions (#1653) ...
PHPC-2346
This removes the BSON functions that were deprecated in favour of the
MongoDB\BSON\Document
class.