Uploaded image for project: 'PHP Driver: Library'
  1. PHP Driver: Library
  2. PHPLIB-389

Implement Client::withOptions() method

    • Type: Icon: New Feature New Feature
    • Resolution: Won't Fix
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None

      Doctrine ODM would benefit from a Client::withOptions() method, similar to what we have for Database and Collection. This would allow it to receive a Client object from the user and apply its own options (i.e. type map, RC/RP/WC).

      This new Client method should behave similarly to the Database and Collection withOptions() methods, which inherit their defaults from local properties (see: Collection::withOptions()).

      However, special care should be taken to ensure that the newly created Client can reuse the same libmongoc client (allowing us to avoid creating new connections unnecessarily). This may entail preserving the original Manager instance between old and new Client, or simply constructing a new Manager but using the same arguments (Client::__construct() would need to preserve those if so).

      In either case, ensuring that we maintain the original libmongoc client will mean that the Client object's own RC/RP/WC properties may no longer be consistent with those from its Manager instance (i.e. the libmongoc client). While this is a subtle internal change, it may not actually be a problem in practice if we ensure that Database and Collection objects inherit the appropriate RC/RP/WC.

      We may thus need to modify the Client's selectDatabase() and selectCollection() methods to pull its defaults from local properties (consistent with the new withOptions() method). Currently, Database and Collection will inherit RC/RP/WC from the Manager if those options are not explicitly provided.

            Assignee:
            andreas.braun@mongodb.com Andreas Braun
            Reporter:
            jmikola@mongodb.com Jeremy Mikola
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: