This adds checks to ensure that explicit sessions and unacknowledged write concerns (explicit or inherited) will not be mixed when executing bulk writes or commands. Additionally, we ensure that command execution does not create its own implicit session (per PHPC-1152) if the effective write concern is unacknowledged.
Note: libmongoc still needs to ensure that it does not create implicit sessions for unacknowledged commands (CDRIVER-2615).
This ensures that phongo_execute_command creates an implicit session (if supported and not explicit session was provided). In turn, this ensures that any command cursor shares the same session as its originating command.
By creating a Session object, we can ensure that the implicit session is destroyed during garbage collection when the last reference is removed.
This corrects the function signatures to return a boolean indicating success instead of an integer (which was cast from a boolean).
Additionally, it restructures phongo_execute_command() to use a cleanup label, in anticipation of implicit session changes.
In libmongoc error API v2, the command domain no longer used for errors originating from the server. It is relegated to MONGOC_ERROR_PROTOCOL_BAD_WIRE_VERSION and MONGOC_ERROR_COMMAND_INVALID_ARG, both of which are client-side errors.
While these tests would certainly pass without SSL enabled, the desired code under test would not even be compiled into the extension.
This also removes an inaccurate code comment.
Execute options are now parsed via php_array functions, which makes the options case-sensitive.
A helper function is now used to convert legacy options for the original three execute methods into an array. This simplifies option parsing in php_phongo.c.
Additionally, Manager methods now perform their own server selection, which means that execute functions in php_phongo.c can rely on a server_id being provided.
Tests have been updated to expect a serverId option when relevant (e.g. query opts). Additionally, error tests for execute methods have been improved so that invalid values for all known options are tested.
This introduces a Session class, which wraps libmongoc's client session object. Additionally, we support a "session" option on Manager and Server execute methods to allow operations to be associated with an explicit session (mostly relevant for causal consistency).
This only updates exceptions where object types are entirely unexpected. For instance, options that expect a BSON document (i.e. array or object) need not use this macro, as any object would be accepted.