Use int64_t API for wTimeoutMS. The initial commit for CDRIVER-3087 deprecated the int32_t API for wTimeoutMS. Migrate to the int64_t API to avoid deprecation warnings. Note: PHPC (and libmongoc's URI parsing) still require 32-bit values for wTimeoutMS, so this does not affect users. Having said that, PHPC-1411 may introduce support for 64-bit values and necessitate changes to the code where we read wTimeoutMS values.
Use mongoc_uri_get_tls to read tls/ssl URI option. As part of CDRIVER-2869, libmongoc deprecated mongoc_uri_get_ssl and introduced a "tls" alias. Migrate to the new API to avoid deprecation warnings.
Expect lowercase URI option in error. As part of CDRIVER-2869, libmongoc does case-folding on option keys to facilitate deduplication.
This allows executeQuery() to throw a CommandException, which exposes the error document.
In 1.6+, it will also ensure that error labels are set on any RuntimeException thrown during cursor iteration, which is relevant for transactions.
executeBulkWrite() will now throw a BulkWriteException on top of any previous exception to ensure that a WriteResult can be attached. InvalidArgumentException is excluded, since that is only thrown before mongoc_bulk_operation_execute does IO (e.g. batch is empty).
This condition was never reached. Apart from code coverage, it's clear that an exception would not be thrown before this point since only libmongoc functions are called.
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.