Problem/Motivation

selectCollection() and selectDatabase() are deprecated in mongodb/mongodb.
The module still calls them in several places.

Steps to reproduce

Not applicable, this is a deprecation cleanup.

Proposed resolution

Replace every call site with getCollection() and getDatabase(), which are
available in all supported library versions (^2.4 || ^1.21). No behaviour change,
these methods are direct equivalents.

Remaining tasks

None.

User interface changes

None.

API changes

None.

Data model changes

None.

Issue fork mongodb-3628021

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

jerome-mongodb created an issue. See original summary.

fgm’s picture

Title: Replace deprecated selectCollection() and selectDatabase() calls » Use getCollection() and getDatabase() instead of the select methods
Status: Active » Reviewed & tested by the community

Hi Jérôme.

Thanks for the MR. The code changes are correct and complete, but I checked the latest driver version and neither method is currently deprecated, although both are now thin wrappers around their get* counterparts. See e.g. https://github.com/mongodb/mongo-php-library/blob/v2.x/src/Client.php#L405 as of today : no deprecation mention

AFAICS that deprecation is only a future step, tracked at https://jira.mongodb.org/browse/PHPLIB-1553 so while the code is correct, the issue title is a bit ahead of reality, so I'm changing it for consistency before merging.

  • fgm committed ee675005 on 8.x-2.x authored by jerome-mongodb
    Issue #3628021: Use getCollection() and getDatabase() instead of the...
fgm’s picture

Status: Reviewed & tested by the community » Fixed

Merged to today's HEAD, thanks. Regarding credits, you don't appear to have associated MongoDB to your work, although they're a long-ago sponsor of the project, so you can add them to the credits for your contributions if you wish.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.