-
Type: New Feature
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
In order to support sessions (PHPC-980), all methods that communicate with the server may need to take a session option. This will require changes to our three execute methods. These methods currently take optional an write concern and read preference as their third argument, which should be changed to an array option. Please support the following:
- executeBulkWrite(string $namespace, BulkWrite $bulk, array $options = [])
- executeCommand(string $namespace, Command $command, array $options = [])
- executeQuery(string $namespace, Query $query, array $options = [])
Note: while we should document the third argument as an array type, the implementations will still need to accept the current parameter type (WriteConcern for executeBulkWrite and ReadPreference for others) for BC support.
The options array should support the following:
- BulkWrite: writeConcern, session
- Command: readPreference, session
- Query: readPreference, session
The session option in PHP should expect our object that abstracts mongoc_client_session_t. When converting this option for libmongoc's opts bson_t, we will pass its ID via the sessionId field.
Note: the general command helper (MONGOC_CMD_RAW mode) only uses the readPreference option for server selection if a server ID is not provided explicitly. If our Manager class will be performing server selection internally (so that we specify a serverId option in libmongo'c opts bson_t), it's likely that a readPreference option would simply be ignored by libmongoc (that's perfectly ok). The readPreference option may still be relevant for the READ mode command helpers (PHPC-834).