This removes the redundant MONGODB_VERSION constant renames the existing version and stability constants to be consistent with the format in PHP's extension skeleton: dcfd753104
This function was originally implemented in PHPC-424, before we started preparing tag sets in PHPC-359 to ensure that they serialized as BSON documents. There is no longer any reason to allow array types here.
This primarily fixes a bug introduced in 6d46d62577 for PHPC-359, since we convert tag sets from arrays to objects to ensure proper BSON serialization. Not only was the array mutation visible to calling contexts, but a crash could occur if the array was immutable due to OPcache.
For Manager's $driverOptions, a comment in 1060cb8ba4 for PHPC-433 indicated that we should have separated its zval due to possible modification, but the appropriate zend_parse_parameters() flag was never used.
Previous initialization during MINIT and using the accessor macro was causing crashes in Apache.
This also declares externs for TSRMLS_CACHE, as is done in other extensions.
This adds an options array to the ReadPreference constructor, which accepts a maxStalenessMS option. The option is also exposed via a getter method and in debug output.
This is necessary since PHP's add_assoc_string_ex() declares the argument as char *, even though it never modifies the string contents and later assigns it to a const char * internally. Since we always duplicate the string for PHP 5.x and it is never modified in PHP 7, there is no harm in this cast.
This adds common validation for read preference tag sets when specified through either the Manager constructor's URI options array or ReadPreference constructor.
An additional test case for a malformed tag set has been added to the Manager::__construct() error test for read preference options. Additionally, the ReadPreference::__construct() error test has been split up to test for mode and tagSet errors separately.
Note: we cannot test for the exceptions for bson_init_static() and mongoc_read_prefs_is_valid(), since those points will never be hit in normal operation.
Clients will be hashed by Manager constructor arguments. Since they must persist between requests, the Manager destructor will no longer free the client and we'll need to start using persistent memory allocation for libbson and libmongoc.
BSON conversion of uriOptions moves to phongo_manager_init(). Merging of stream context options into driverOptions and removal of the context resource is now done in the Manager constructor.
phongo_manager_init() now has zvals for both uriOptions and driverOptions and will be able to serialize them with the URI string for a client hash.
This changes behavior of var_dump(), var_export(), and serialization.
Additionally, this renames the internal struct fields to be consistent with the publicized property names.