Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -296,13 +296,13 @@ if test "$PHP_MONGODB" != "no"; then
PHP_MONGODB_COMMON_SOURCES="common-b64.c"

dnl Generated with: find src/libmongoc/src/libbson/src/bson -name '*.c' -print0 | cut -sz -d / -f 7- | sort -z | tr '\000' ' '
PHP_MONGODB_BSON_SOURCES="bcon.c bson-atomic.c bson.c bson-clock.c bson-context.c bson-decimal128.c bson-error.c bson-iso8601.c bson-iter.c bson-json.c bson-keys.c bson-md5.c bson-memory.c bson-oid.c bson-reader.c bson-string.c bson-timegm.c bson-utf8.c bson-value.c bson-version-functions.c bson-writer.c"
PHP_MONGODB_BSON_SOURCES="bcon.c bson-atomic.c bson.c bson-clock.c bson-context.c bson-decimal128.c bson-error.c bson-fnv.c bson-iso8601.c bson-iter.c bson-json.c bson-keys.c bson-md5.c bson-memory.c bson-oid.c bson-reader.c bson-string.c bson-timegm.c bson-utf8.c bson-value.c bson-version-functions.c bson-writer.c"

dnl Generated with: find src/libmongoc/src/libbson/src/jsonsl -name '*.c' -print0 | cut -sz -d / -f 7- | sort -z | tr '\000' ' '
PHP_MONGODB_JSONSL_SOURCES="jsonsl.c"

dnl Generated with: find src/libmongoc/src/libmongoc/src/mongoc -name '*.c' -print0 | cut -sz -d / -f 7- | sort -z | tr '\000' ' '
PHP_MONGODB_MONGOC_SOURCES="mongoc-apm.c mongoc-array.c mongoc-async.c mongoc-async-cmd.c mongoc-buffer.c mongoc-bulk-operation.c mongoc-change-stream.c mongoc-client.c mongoc-client-pool.c mongoc-client-session.c mongoc-cluster.c mongoc-cluster-cyrus.c mongoc-cluster-gssapi.c mongoc-cluster-sasl.c mongoc-cluster-sspi.c mongoc-cmd.c mongoc-collection.c mongoc-compression.c mongoc-counters.c mongoc-crypto.c mongoc-crypto-cng.c mongoc-crypto-common-crypto.c mongoc-crypto-openssl.c mongoc-cursor-array.c mongoc-cursor.c mongoc-cursor-cmd.c mongoc-cursor-cmd-deprecated.c mongoc-cursor-find.c mongoc-cursor-find-cmd.c mongoc-cursor-find-opquery.c mongoc-cursor-legacy.c mongoc-cyrus.c mongoc-database.c mongoc-find-and-modify.c mongoc-gridfs.c mongoc-gridfs-file.c mongoc-gridfs-file-list.c mongoc-gridfs-file-page.c mongoc-gssapi.c mongoc-handshake.c mongoc-host-list.c mongoc-index.c mongoc-init.c mongoc-libressl.c mongoc-linux-distro-scanner.c mongoc-list.c mongoc-log.c mongoc-matcher.c mongoc-matcher-op.c mongoc-memcmp.c mongoc-openssl.c mongoc-opts.c mongoc-opts-helpers.c mongoc-queue.c mongoc-rand-cng.c mongoc-rand-common-crypto.c mongoc-rand-openssl.c mongoc-read-concern.c mongoc-read-prefs.c mongoc-rpc.c mongoc-sasl.c mongoc-scram.c mongoc-secure-channel.c mongoc-secure-transport.c mongoc-server-description.c mongoc-server-stream.c mongoc-set.c mongoc-socket.c mongoc-ssl.c mongoc-sspi.c mongoc-stream-buffered.c mongoc-stream.c mongoc-stream-file.c mongoc-stream-gridfs.c mongoc-stream-socket.c mongoc-stream-tls.c mongoc-stream-tls-libressl.c mongoc-stream-tls-openssl-bio.c mongoc-stream-tls-openssl.c mongoc-stream-tls-secure-channel.c mongoc-stream-tls-secure-transport.c mongoc-topology.c mongoc-topology-description-apm.c mongoc-topology-description.c mongoc-topology-scanner.c mongoc-uri.c mongoc-util.c mongoc-version-functions.c mongoc-write-command.c mongoc-write-command-legacy.c mongoc-write-concern.c"
PHP_MONGODB_MONGOC_SOURCES="mongoc-apm.c mongoc-array.c mongoc-async.c mongoc-async-cmd.c mongoc-buffer.c mongoc-bulk-operation.c mongoc-change-stream.c mongoc-client.c mongoc-client-pool.c mongoc-client-session.c mongoc-cluster.c mongoc-cluster-cyrus.c mongoc-cluster-gssapi.c mongoc-cluster-sasl.c mongoc-cluster-sspi.c mongoc-cmd.c mongoc-collection.c mongoc-compression.c mongoc-counters.c mongoc-crypto.c mongoc-crypto-cng.c mongoc-crypto-common-crypto.c mongoc-crypto-openssl.c mongoc-cursor-array.c mongoc-cursor.c mongoc-cursor-cmd.c mongoc-cursor-cmd-deprecated.c mongoc-cursor-find.c mongoc-cursor-find-cmd.c mongoc-cursor-find-opquery.c mongoc-cursor-legacy.c mongoc-cyrus.c mongoc-database.c mongoc-error.c mongoc-find-and-modify.c mongoc-gridfs.c mongoc-gridfs-file.c mongoc-gridfs-file-list.c mongoc-gridfs-file-page.c mongoc-gssapi.c mongoc-handshake.c mongoc-host-list.c mongoc-index.c mongoc-init.c mongoc-libressl.c mongoc-linux-distro-scanner.c mongoc-list.c mongoc-log.c mongoc-matcher.c mongoc-matcher-op.c mongoc-memcmp.c mongoc-openssl.c mongoc-opts.c mongoc-opts-helpers.c mongoc-queue.c mongoc-rand-cng.c mongoc-rand-common-crypto.c mongoc-rand-openssl.c mongoc-read-concern.c mongoc-read-prefs.c mongoc-rpc.c mongoc-sasl.c mongoc-scram.c mongoc-secure-channel.c mongoc-secure-transport.c mongoc-server-description.c mongoc-server-stream.c mongoc-set.c mongoc-socket.c mongoc-ssl.c mongoc-sspi.c mongoc-stream-buffered.c mongoc-stream.c mongoc-stream-file.c mongoc-stream-gridfs.c mongoc-stream-socket.c mongoc-stream-tls.c mongoc-stream-tls-libressl.c mongoc-stream-tls-openssl-bio.c mongoc-stream-tls-openssl.c mongoc-stream-tls-secure-channel.c mongoc-stream-tls-secure-transport.c mongoc-topology.c mongoc-topology-description-apm.c mongoc-topology-description.c mongoc-topology-scanner.c mongoc-uri.c mongoc-util.c mongoc-version-functions.c mongoc-write-command.c mongoc-write-command-legacy.c mongoc-write-concern.c"

dnl Generated with: find src/libmongoc/src/zlib-1.2.11 -maxdepth 1 -name '*.c' -print0 | cut -sz -d / -f 5- | sort -z | tr '\000' ' '
PHP_MONGODB_ZLIB_SOURCES="adler32.c compress.c crc32.c deflate.c gzclose.c gzlib.c gzread.c gzwrite.c infback.c inffast.c inflate.c inftrees.c trees.c uncompr.c zutil.c"
Expand Down
4 changes: 2 additions & 2 deletions config.w32
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ if (PHP_MONGODB != "no") {
var PHP_MONGODB_COMMON_SOURCES="common-b64.c"

// Generated with: find src/libmongoc/src/libbson/src/bson -name '*.c' -print0 | cut -sz -d / -f 7- | sort -z | tr '\000' ' '
var PHP_MONGODB_BSON_SOURCES="bcon.c bson-atomic.c bson.c bson-clock.c bson-context.c bson-decimal128.c bson-error.c bson-iso8601.c bson-iter.c bson-json.c bson-keys.c bson-md5.c bson-memory.c bson-oid.c bson-reader.c bson-string.c bson-timegm.c bson-utf8.c bson-value.c bson-version-functions.c bson-writer.c";
var PHP_MONGODB_BSON_SOURCES="bcon.c bson-atomic.c bson.c bson-clock.c bson-context.c bson-decimal128.c bson-error.c bson-fnv.c bson-iso8601.c bson-iter.c bson-json.c bson-keys.c bson-md5.c bson-memory.c bson-oid.c bson-reader.c bson-string.c bson-timegm.c bson-utf8.c bson-value.c bson-version-functions.c bson-writer.c";

// Generated with: find src/libmongoc/src/libbson/src/jsonsl -name '*.c' -print0 | cut -sz -d / -f 7- | sort -z | tr '\000' ' '
var PHP_MONGODB_JSONSL_SOURCES="jsonsl.c";

// Generated with: find src/libmongoc/src/libmongoc/src/mongoc -name '*.c' -print0 | cut -sz -d / -f 7- | sort -z | tr '\000' ' '
var PHP_MONGODB_MONGOC_SOURCES="mongoc-apm.c mongoc-array.c mongoc-async.c mongoc-async-cmd.c mongoc-buffer.c mongoc-bulk-operation.c mongoc-change-stream.c mongoc-client.c mongoc-client-pool.c mongoc-client-session.c mongoc-cluster.c mongoc-cluster-cyrus.c mongoc-cluster-gssapi.c mongoc-cluster-sasl.c mongoc-cluster-sspi.c mongoc-cmd.c mongoc-collection.c mongoc-compression.c mongoc-counters.c mongoc-crypto.c mongoc-crypto-cng.c mongoc-crypto-common-crypto.c mongoc-crypto-openssl.c mongoc-cursor-array.c mongoc-cursor.c mongoc-cursor-cmd.c mongoc-cursor-cmd-deprecated.c mongoc-cursor-find.c mongoc-cursor-find-cmd.c mongoc-cursor-find-opquery.c mongoc-cursor-legacy.c mongoc-cyrus.c mongoc-database.c mongoc-find-and-modify.c mongoc-gridfs.c mongoc-gridfs-file.c mongoc-gridfs-file-list.c mongoc-gridfs-file-page.c mongoc-gssapi.c mongoc-handshake.c mongoc-host-list.c mongoc-index.c mongoc-init.c mongoc-libressl.c mongoc-linux-distro-scanner.c mongoc-list.c mongoc-log.c mongoc-matcher.c mongoc-matcher-op.c mongoc-memcmp.c mongoc-openssl.c mongoc-opts.c mongoc-opts-helpers.c mongoc-queue.c mongoc-rand-cng.c mongoc-rand-common-crypto.c mongoc-rand-openssl.c mongoc-read-concern.c mongoc-read-prefs.c mongoc-rpc.c mongoc-sasl.c mongoc-scram.c mongoc-secure-channel.c mongoc-secure-transport.c mongoc-server-description.c mongoc-server-stream.c mongoc-set.c mongoc-socket.c mongoc-ssl.c mongoc-sspi.c mongoc-stream-buffered.c mongoc-stream.c mongoc-stream-file.c mongoc-stream-gridfs.c mongoc-stream-socket.c mongoc-stream-tls.c mongoc-stream-tls-libressl.c mongoc-stream-tls-openssl-bio.c mongoc-stream-tls-openssl.c mongoc-stream-tls-secure-channel.c mongoc-stream-tls-secure-transport.c mongoc-topology.c mongoc-topology-description-apm.c mongoc-topology-description.c mongoc-topology-scanner.c mongoc-uri.c mongoc-util.c mongoc-version-functions.c mongoc-write-command.c mongoc-write-command-legacy.c mongoc-write-concern.c";
var PHP_MONGODB_MONGOC_SOURCES="mongoc-apm.c mongoc-array.c mongoc-async.c mongoc-async-cmd.c mongoc-buffer.c mongoc-bulk-operation.c mongoc-change-stream.c mongoc-client.c mongoc-client-pool.c mongoc-client-session.c mongoc-cluster.c mongoc-cluster-cyrus.c mongoc-cluster-gssapi.c mongoc-cluster-sasl.c mongoc-cluster-sspi.c mongoc-cmd.c mongoc-collection.c mongoc-compression.c mongoc-counters.c mongoc-crypto.c mongoc-crypto-cng.c mongoc-crypto-common-crypto.c mongoc-crypto-openssl.c mongoc-cursor-array.c mongoc-cursor.c mongoc-cursor-cmd.c mongoc-cursor-cmd-deprecated.c mongoc-cursor-find.c mongoc-cursor-find-cmd.c mongoc-cursor-find-opquery.c mongoc-cursor-legacy.c mongoc-cyrus.c mongoc-database.c mongoc-error.c mongoc-find-and-modify.c mongoc-gridfs.c mongoc-gridfs-file.c mongoc-gridfs-file-list.c mongoc-gridfs-file-page.c mongoc-gssapi.c mongoc-handshake.c mongoc-host-list.c mongoc-index.c mongoc-init.c mongoc-libressl.c mongoc-linux-distro-scanner.c mongoc-list.c mongoc-log.c mongoc-matcher.c mongoc-matcher-op.c mongoc-memcmp.c mongoc-openssl.c mongoc-opts.c mongoc-opts-helpers.c mongoc-queue.c mongoc-rand-cng.c mongoc-rand-common-crypto.c mongoc-rand-openssl.c mongoc-read-concern.c mongoc-read-prefs.c mongoc-rpc.c mongoc-sasl.c mongoc-scram.c mongoc-secure-channel.c mongoc-secure-transport.c mongoc-server-description.c mongoc-server-stream.c mongoc-set.c mongoc-socket.c mongoc-ssl.c mongoc-sspi.c mongoc-stream-buffered.c mongoc-stream.c mongoc-stream-file.c mongoc-stream-gridfs.c mongoc-stream-socket.c mongoc-stream-tls.c mongoc-stream-tls-libressl.c mongoc-stream-tls-openssl-bio.c mongoc-stream-tls-openssl.c mongoc-stream-tls-secure-channel.c mongoc-stream-tls-secure-transport.c mongoc-topology.c mongoc-topology-description-apm.c mongoc-topology-description.c mongoc-topology-scanner.c mongoc-uri.c mongoc-util.c mongoc-version-functions.c mongoc-write-command.c mongoc-write-command-legacy.c mongoc-write-concern.c";

EXTENSION("mongodb", "php_phongo.c phongo_compat.c", null, PHP_MONGODB_CFLAGS);
ADD_SOURCES(configure_module_dirname + "/src", "bson.c bson-encode.c", "mongodb");
Expand Down
28 changes: 14 additions & 14 deletions php_phongo.c
Original file line number Diff line number Diff line change
Expand Up @@ -1788,7 +1788,6 @@ static bool php_phongo_apply_rp_options_to_uri(mongoc_uri_t* uri, bson_t* option
static bool php_phongo_apply_wc_options_to_uri(mongoc_uri_t* uri, bson_t* options TSRMLS_DC) /* {{{ */
{
bson_iter_t iter;
int32_t wtimeoutms;
mongoc_write_concern_t* new_wc;
const mongoc_write_concern_t* old_wc;

Expand All @@ -1811,8 +1810,6 @@ static bool php_phongo_apply_wc_options_to_uri(mongoc_uri_t* uri, bson_t* option
return true;
}

wtimeoutms = mongoc_write_concern_get_wtimeout(old_wc);

new_wc = mongoc_write_concern_copy(old_wc);

if (bson_iter_init_find_case(&iter, options, MONGOC_URI_SAFE)) {
Expand All @@ -1827,14 +1824,25 @@ static bool php_phongo_apply_wc_options_to_uri(mongoc_uri_t* uri, bson_t* option
}

if (bson_iter_init_find_case(&iter, options, MONGOC_URI_WTIMEOUTMS)) {
int32_t wtimeout;

if (!BSON_ITER_HOLDS_INT32(&iter)) {
PHONGO_URI_INVALID_TYPE(iter, "32-bit integer");
mongoc_write_concern_destroy(new_wc);

return false;
}

wtimeoutms = bson_iter_int32(&iter);
wtimeout = bson_iter_int32(&iter);

if (wtimeout < 0) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Expected wtimeoutMS to be >= 0, %d given", wtimeout);
mongoc_write_concern_destroy(new_wc);

return false;
}

mongoc_write_concern_set_wtimeout(new_wc, wtimeout);
}

if (bson_iter_init_find_case(&iter, options, MONGOC_URI_JOURNAL)) {
Expand Down Expand Up @@ -1872,7 +1880,8 @@ static bool php_phongo_apply_wc_options_to_uri(mongoc_uri_t* uri, bson_t* option
const char* str = bson_iter_utf8(&iter, NULL);

if (0 == strcasecmp(PHONGO_WRITE_CONCERN_W_MAJORITY, str)) {
mongoc_write_concern_set_wmajority(new_wc, wtimeoutms);
/* wtimeoutMS is set independently, so preserve its value here */
mongoc_write_concern_set_wmajority(new_wc, mongoc_write_concern_get_wtimeout(new_wc));
} else {
mongoc_write_concern_set_wtag(new_wc, str);
}
Expand All @@ -1884,15 +1893,6 @@ static bool php_phongo_apply_wc_options_to_uri(mongoc_uri_t* uri, bson_t* option
}
}

/* Only set wtimeout if it's still applicable; otherwise, clear it. */
if (mongoc_write_concern_get_w(new_wc) > 1 ||
mongoc_write_concern_get_wmajority(new_wc) ||
mongoc_write_concern_get_wtag(new_wc)) {
mongoc_write_concern_set_wtimeout(new_wc, wtimeoutms);
} else {
mongoc_write_concern_set_wtimeout(new_wc, 0);
}

if (mongoc_write_concern_get_journal(new_wc)) {
int32_t w = mongoc_write_concern_get_w(new_wc);

Expand Down
2 changes: 1 addition & 1 deletion src/libmongoc
Submodule libmongoc updated 87 files
+1 −1 CONTRIBUTING.md
+70 −6 NEWS
+1 −1 VERSION_CURRENT
+1 −1 VERSION_RELEASED
+1 −0 src/libbson/CMakeLists.txt
+44 −4 src/libbson/NEWS
+18 −0 src/libbson/THIRD_PARTY_NOTICES
+1 −1 src/libbson/doc/bson_md5_t.rst
+1 −1 src/libbson/doc/oid.rst
+2 −0 src/libbson/src/bson/CMakeLists.txt
+1 −1 src/libbson/src/bson/bson-context-private.h
+14 −18 src/libbson/src/bson/bson-context.c
+25 −0 src/libbson/src/bson/bson-fnv-private.h
+90 −0 src/libbson/src/bson/bson-fnv.c
+1 −2 src/libbson/src/bson/bson-oid.c
+207 −0 src/libbson/tests/test-fnv.c
+2 −0 src/libmongoc/CMakeLists.txt
+37 −0 src/libmongoc/doc/errors.rst
+ src/libmongoc/doc/libbson-objects.inv
+2 −0 src/libmongoc/doc/mongoc_change_stream_t.rst
+2 −0 src/libmongoc/doc/mongoc_client_session_start_transaction.rst
+1 −0 src/libmongoc/doc/mongoc_client_t.rst
+55 −0 src/libmongoc/doc/mongoc_client_watch.rst
+9 −2 src/libmongoc/doc/mongoc_collection_watch.rst
+1 −0 src/libmongoc/doc/mongoc_database_t.rst
+55 −0 src/libmongoc/doc/mongoc_database_watch.rst
+25 −0 src/libmongoc/doc/mongoc_error_has_label.rst
+1 −0 src/libmongoc/doc/mongoc_read_concern_t.rst
+9 −36 src/libmongoc/examples/example-transaction.c
+1 −0 src/libmongoc/src/mongoc/CMakeLists.txt
+33 −24 src/libmongoc/src/mongoc/mongoc-bulk-operation.c
+30 −5 src/libmongoc/src/mongoc/mongoc-change-stream-private.h
+186 −61 src/libmongoc/src/mongoc/mongoc-change-stream.c
+3 −0 src/libmongoc/src/mongoc/mongoc-client-private.h
+7 −2 src/libmongoc/src/mongoc/mongoc-client-session.c
+123 −76 src/libmongoc/src/mongoc/mongoc-client.c
+4 −0 src/libmongoc/src/mongoc/mongoc-client.h
+5 −0 src/libmongoc/src/mongoc/mongoc-cluster-private.h
+46 −21 src/libmongoc/src/mongoc/mongoc-cluster.c
+1 −1 src/libmongoc/src/mongoc/mongoc-cmd.c
+244 −175 src/libmongoc/src/mongoc/mongoc-collection.c
+3 −3 src/libmongoc/src/mongoc/mongoc-cursor-array.c
+8 −3 src/libmongoc/src/mongoc/mongoc-cursor-cmd-deprecated.c
+6 −2 src/libmongoc/src/mongoc/mongoc-cursor-cmd.c
+4 −3 src/libmongoc/src/mongoc/mongoc-cursor-find.c
+4 −2 src/libmongoc/src/mongoc/mongoc-cursor-private.h
+43 −6 src/libmongoc/src/mongoc/mongoc-cursor.c
+39 −25 src/libmongoc/src/mongoc/mongoc-database.c
+4 −0 src/libmongoc/src/mongoc/mongoc-database.h
+41 −0 src/libmongoc/src/mongoc/mongoc-error.c
+4 −0 src/libmongoc/src/mongoc/mongoc-error.h
+1 −0 src/libmongoc/src/mongoc/mongoc-gridfs-file-list.c
+2 −1 src/libmongoc/src/mongoc/mongoc-gridfs.c
+1 −0 src/libmongoc/src/mongoc/mongoc-read-concern.h
+5 −6 src/libmongoc/src/mongoc/mongoc-rpc-private.h
+99 −47 src/libmongoc/src/mongoc/mongoc-rpc.c
+4 −6 src/libmongoc/src/mongoc/mongoc-server-description.c
+7 −4 src/libmongoc/src/mongoc/mongoc-uri.c
+7 −3 src/libmongoc/src/mongoc/mongoc-util-private.h
+67 −29 src/libmongoc/src/mongoc/mongoc-util.c
+11 −2 src/libmongoc/src/mongoc/mongoc-write-command-private.h
+41 −26 src/libmongoc/src/mongoc/mongoc-write-command.c
+14 −0 src/libmongoc/tests/json-test-monitoring.c
+216 −110 src/libmongoc/tests/json-test-operations.c
+5 −10 src/libmongoc/tests/json-test.c
+476 −0 src/libmongoc/tests/json/transactions/error-labels.json
+550 −0 src/libmongoc/tests/json/transactions/opts.json
+281 −0 src/libmongoc/tests/json/transactions/opts.yml
+292 −0 src/libmongoc/tests/json/transactions/run-command.json
+15 −3 src/libmongoc/tests/mock_server/mock-server.c
+1 −0 src/libmongoc/tests/mock_server/mock-server.h
+18 −0 src/libmongoc/tests/test-libmongoc.c
+5 −9 src/libmongoc/tests/test-libmongoc.h
+64 −11 src/libmongoc/tests/test-mongoc-bulk.c
+272 −2 src/libmongoc/tests/test-mongoc-change-stream.c
+3 −2 src/libmongoc/tests/test-mongoc-cluster.c
+32 −19 src/libmongoc/tests/test-mongoc-collection.c
+2 −2 src/libmongoc/tests/test-mongoc-cursor.c
+2 −1 src/libmongoc/tests/test-mongoc-cyrus.c
+11 −0 src/libmongoc/tests/test-mongoc-error.c
+6 −2 src/libmongoc/tests/test-mongoc-exhaust.c
+134 −54 src/libmongoc/tests/test-mongoc-read-write-concern.c
+492 −1 src/libmongoc/tests/test-mongoc-sample-commands.c
+14 −13 src/libmongoc/tests/test-mongoc-topology-reconcile.c
+74 −46 src/libmongoc/tests/test-mongoc-topology.c
+193 −8 src/libmongoc/tests/test-mongoc-transactions.c
+4 −2 src/libmongoc/tests/test-mongoc-write-commands.c
5 changes: 4 additions & 1 deletion tests/manager/manager-ctor-write_concern-002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ MongoDB\Driver\Manager::__construct(): write concern options (wtimeoutms)
<?php

$tests = [
// wtimeoutms does not get applied unless w > 1, w = majority, or tag sets are used
['mongodb://127.0.0.1/?wtimeoutms=1000', []],
['mongodb://127.0.0.1/?w=2&wtimeoutms=1000', []],
['mongodb://127.0.0.1/?w=majority&wtimeoutms=1000', []],
Expand All @@ -27,6 +26,8 @@ foreach ($tests as $test) {
<?php exit(0); ?>
--EXPECTF--
object(MongoDB\Driver\WriteConcern)#%d (%d) {
["wtimeout"]=>
int(1000)
}
object(MongoDB\Driver\WriteConcern)#%d (%d) {
["w"]=>
Expand All @@ -47,6 +48,8 @@ object(MongoDB\Driver\WriteConcern)#%d (%d) {
int(1000)
}
object(MongoDB\Driver\WriteConcern)#%d (%d) {
["wtimeout"]=>
int(1000)
}
object(MongoDB\Driver\WriteConcern)#%d (%d) {
["w"]=>
Expand Down
6 changes: 3 additions & 3 deletions tests/manager/manager-ctor-write_concern-error-004.phpt
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
--TEST--
MongoDB\Driver\Manager::__construct(): invalid write concern (wtimeoutms range)
MongoDB\Driver\Manager::__construct(): invalid write concern (wtimeoutms range exceeds INT32_MAX)
--SKIPIF--
<?php if (8 !== PHP_INT_SIZE) { die('skip Only for 64-bit platform'); } ?>
--FILE--
<?php

require_once __DIR__ . '/../utils/tools.php';

/* Note: libmongoc does not check wTimeoutMS's range in the URI string. 64-bit
* integers will be truncated by strtol() */
/* Note: libmongoc does not check wTimeoutMS's upper bounds in the URI string.
* 64-bit integers will be truncated by strtol(). */

echo throws(function() {
new MongoDB\Driver\Manager(null, ['wTimeoutMS' => 2147483648]);
Expand Down
20 changes: 20 additions & 0 deletions tests/manager/manager-ctor-write_concern-error-007.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--TEST--
MongoDB\Driver\Manager::__construct(): invalid write concern (wtimeoutms range)
--SKIPIF--
<?php if (8 !== PHP_INT_SIZE) { die('skip Only for 64-bit platform'); } ?>
--FILE--
<?php

require_once __DIR__ . '/../utils/tools.php';

echo throws(function() {
new MongoDB\Driver\Manager(null, ['wTimeoutMS' => -1]);
}, "MongoDB\Driver\Exception\InvalidArgumentException"), "\n";

?>
===DONE===
<?php exit(0); ?>
--EXPECT--
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
Expected wtimeoutMS to be >= 0, -1 given
===DONE===
5 changes: 4 additions & 1 deletion tests/manager/manager-getwriteconcern-001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ $tests = array(
array(null, array('w' => 1, 'journal' => true)),
array(null, array('w' => 'majority', 'journal' => true)),
array('mongodb://127.0.0.1/?w=majority&journal=true', array('w' => 1, 'journal' => false)),
// wtimeoutms does not get applied unless w > 1, w = majority, or tag sets are used
array('mongodb://127.0.0.1/?wtimeoutms=1000', array()),
array(null, array('wtimeoutms' => 1000)),
array('mongodb://127.0.0.1/?w=2', array('wtimeoutms' => 1000)),
Expand Down Expand Up @@ -61,8 +60,12 @@ object(MongoDB\Driver\WriteConcern)#%d (%d) {
bool(false)
}
object(MongoDB\Driver\WriteConcern)#%d (%d) {
["wtimeout"]=>
int(1000)
}
object(MongoDB\Driver\WriteConcern)#%d (%d) {
["wtimeout"]=>
int(1000)
}
object(MongoDB\Driver\WriteConcern)#%d (%d) {
["w"]=>
Expand Down