-
Notifications
You must be signed in to change notification settings - Fork 208
PHPC-2347: Deprecate BSON functions #1607
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-2347: Deprecate BSON functions #1607
Conversation
Test#0 { "binary" : { "$binary" : "cmFuZG9tQmluYXJ5RGF0YQ==", "$type" : "00" } } | ||
string(73) "{ "binary" : { "$binary" : "cmFuZG9tQmluYXJ5RGF0YQ==", "$type" : "00" } }" | ||
string(73) "{ "binary" : { "$binary" : "cmFuZG9tQmluYXJ5RGF0YQ==", "$type" : "00" } }" | ||
Test#0 { "binary" : { "$binary" : { "base64" : "cmFuZG9tQmluYXJ5RGF0YQ==", "subType" : "00" } } } |
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 tests all used to print toJSON
, which we did not implement in the Document class. Using relaxed extended JSON is responsible for the additional properties.
|
||
function fetch($bson, $typeMap = []) | ||
{ | ||
for ($i = 0; $i < 25000; $i++) { |
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.
This test was originally added to check for a memory leak, but I figured that we don't need that regression test, especially since it would create 100000 deprecation notices and thus takes a considerable amount of time to run.
@@ -809,22 +809,22 @@ function failMaxTimeMS(Server $server) | |||
} | |||
|
|||
function toPHP($var, $typemap = array()) { |
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.
These are the utility functions I mentioned in the PR description. I'd like to remove these in a separate step for some more efficient handling of data and/or better test output.
} | ||
function toJSON($var) { | ||
return MongoDB\BSON\toJSON($var); | ||
return MongoDB\BSON\Document::fromBSON($var)->toCanonicalExtendedJSON(); |
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 change from toJSON
to toCanonicalExtendedJSON
is responsible for most of the test changes.
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.
In order to avoid accounting for deprecations in BSON corpus tests, I've removed the corresponding calls in those.
LGTM, since they are aliases, no need for extensive tests.
* master: (22 commits) PHPC-2434: Add PHP 8.4 to GitHub Actions (#1625) PHPC-2421, PHPC-2428: Update bundled dependencies (#1622) Don't build libmongoc version in pull requests Use drivers-evergreen-tools for Windows testing (#1615) PHPC-1957 Add tests for out-of-range UTCDateTime values (#1614) PHPC-2286 Implement `UTCDateTime::toDateTimeImmutable` (#1611) PHPC-2414, PHPC-2415: Update wire versions for MongoDB 8.0 compatibility (#1610) PHPC-2349, PHPC-2411: Deprecate unused exception classes (#1608) Fix failing tests on x86 systems (#1609) PHPC-2347: Deprecate BSON functions (#1607) PHPC-1489: Deprecate integer readPreference constants (#1604) Fix version computation for libmongoc development versions (#1599) PHPC-2376: Test against MongoDB 8.0 (#1598) PHPC-2254: Relax server selection timeout error message pattern (#1587) PHPC-2401: Support QEv2 range protocol (#1583) PHPC-2398: Use server_id methods for libmongoc 1.28+ (#1582) PHPC-2395: Fetch Atlas connectivity URIs from AWS Secrets Manager (#1579) Merge v1.19 into master (#1578) Revert "Bump mongodb-labs/drivers-github-tools from 1 to 2 (#1568)" (#1571) Bump mongodb-labs/drivers-github-tools from 1 to 2 (#1568) ...
PHPC-2347
This deprecates all functions in the
MongoDB\BSON
namespace in favour of theMongoDB\BSON\Document
class. I've changed test usages of these functions to the Document class, except where we specifically want to test the functions. Note that tests often use functions liketoPHP
without a namespace - these were proxy functions and were changed to use the Document class internally, even though this is not very efficient. I plan to refactor those utility functions in a separate PR. In order to avoid accounting for deprecations in BSON corpus tests, I've removed the corresponding calls in those. Let me know if that's a concern.