diff --git a/config.m4 b/config.m4 index 88cfff0ed..65af3d885 100644 --- a/config.m4 +++ b/config.m4 @@ -127,6 +127,7 @@ if test "$MONGODB" != "no"; then PHP_CHECK_GCC_ARG(-Wempty-body, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wempty-body") PHP_CHECK_GCC_ARG(-Wparentheses, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wparentheses") PHP_CHECK_GCC_ARG(-Wdeclaration-after-statement, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wdeclaration-after-statement") + PHP_CHECK_GCC_ARG(-Wmaybe-uninitialized, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wmaybe-uninitialized") PHP_CHECK_GCC_ARG(-Werror, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Werror") PHP_CHECK_GCC_ARG(-Wextra, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wextra") PHP_CHECK_GCC_ARG(-Wno-unused-parameter, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wno-unused-parameter") @@ -280,7 +281,7 @@ if test "$MONGODB" != "no"; then PHP_MONGODB_MONGOC_CFLAGS="$STD_CFLAGS -DMONGOC_COMPILATION -DMONGOC_TRACE" dnl Generated with: find src/libmongoc/src/mongoc -name '*.c' -print0 | cut -sz -d / -f 5- | sort -z | tr '\000' ' ' - PHP_MONGODB_MONGOC_SOURCES="mongoc-apm.c mongoc-array.c mongoc-async.c mongoc-async-cmd.c mongoc-b64.c mongoc-buffer.c mongoc-bulk-operation.c mongoc-client.c mongoc-client-pool.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-cursorid.c mongoc-cursor-transform.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-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-concern.c" + PHP_MONGODB_MONGOC_SOURCES="mongoc-apm.c mongoc-array.c mongoc-async.c mongoc-async-cmd.c mongoc-b64.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-cursorid.c mongoc-cursor-transform.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-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_ADD_SOURCES_X(PHP_EXT_DIR(mongodb)[src/libmongoc/src/mongoc], $PHP_MONGODB_MONGOC_SOURCES, $PHP_MONGODB_MONGOC_CFLAGS, shared_objects_mongodb, yes) @@ -296,7 +297,7 @@ if test "$MONGODB" != "no"; then AC_SUBST(MONGOC_ENABLE_CRYPTO_LIBCRYPTO, 1) AC_SUBST(MONGOC_ENABLE_SSL_OPENSSL, 1) - AC_CHECK_DECLS([ASN1_STRING_get0_data], [AC_SUBST(MONGOC_HAVE_ASN1_STRING_GET0_DATA, 1)], [AC_SUBST(MONGOC_HAVE_ASN1_STRING_GET0_DATA, 1)], [[#include ]]) + AC_CHECK_DECLS([ASN1_STRING_get0_data], [AC_SUBST(MONGOC_HAVE_ASN1_STRING_GET0_DATA, 1)], [AC_SUBST(MONGOC_HAVE_ASN1_STRING_GET0_DATA, 0)], [[#include ]]) ]) if test "$PHP_SYSTEM_CIPHERS" != "no"; then @@ -374,6 +375,7 @@ if test "$MONGODB" != "no"; then m4_include(src/libmongoc/build/autotools/m4/ax_prototype.m4) m4_include(src/libmongoc/build/autotools/CheckCompiler.m4) + m4_include(src/libmongoc/build/autotools/FindResSearch.m4) m4_include(src/libmongoc/build/autotools/WeakSymbols.m4) m4_include(src/libmongoc/build/autotools/m4/ax_pthread.m4) AX_PTHREAD diff --git a/config.w32 b/config.w32 index 8ba9c72b4..167f8e22c 100644 --- a/config.w32 +++ b/config.w32 @@ -80,7 +80,7 @@ if (PHP_MONGODB != "no") { var PHP_MONGODB_JSONSL_SOURCES="jsonsl.c"; // Generated with: find src/libmongoc/src/mongoc -name '*.c' -print0 | cut -sz -d / -f 4- | sort -z | tr '\000' ' ' - var PHP_MONGODB_MONGOC_SOURCES="mongoc-apm.c mongoc-array.c mongoc-async.c mongoc-async-cmd.c mongoc-b64.c mongoc-buffer.c mongoc-bulk-operation.c mongoc-client.c mongoc-client-pool.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-cursorid.c mongoc-cursor-transform.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-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-concern.c"; + var PHP_MONGODB_MONGOC_SOURCES="mongoc-apm.c mongoc-array.c mongoc-async.c mongoc-async-cmd.c mongoc-b64.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-cursorid.c mongoc-cursor-transform.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-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"); diff --git a/php_phongo.c b/php_phongo.c index c932e3372..d17d5e809 100644 --- a/php_phongo.c +++ b/php_phongo.c @@ -590,48 +590,84 @@ int phongo_execute_query(mongoc_client_t *client, const char *namespace, zval *z return true; } /* }}} */ +static bson_t *create_wrapped_command_envelope(const char *db, bson_t *reply) +{ + bson_t *tmp; + size_t max_ns_len = strlen(db) + 5 + 1; /* db + ".$cmd" + '\0' */ + char *ns = emalloc(max_ns_len); + + snprintf(ns, max_ns_len, "%s.$cmd", db); + tmp = BCON_NEW("cursor", "{", "id", BCON_INT64(0), "ns", BCON_UTF8(ns), "firstBatch", "[", BCON_DOCUMENT(reply), "]", "}"); + efree(ns); + + return tmp; +} + int phongo_execute_command(mongoc_client_t *client, const char *db, zval *zcommand, zval *zreadPreference, int server_id, zval *return_value, int return_value_used TSRMLS_DC) /* {{{ */ { const php_phongo_command_t *command; - mongoc_cursor_t *cursor; bson_iter_t iter; + bson_t reply; + bson_error_t error; + bson_t *opts; + mongoc_cursor_t *cmd_cursor; + uint32_t selected_server_id; command = Z_COMMAND_OBJ_P(zcommand); - cursor = mongoc_client_command(client, db, MONGOC_QUERY_NONE, 0, 1, 0, command->bson, NULL, phongo_read_preference_from_zval(zreadPreference TSRMLS_CC)); + opts = bson_new(); + if (server_id > 0) { + bson_append_int32(opts, "serverId", -1, server_id); + selected_server_id = server_id; + } else { + mongoc_server_description_t *selected_server = NULL; - if (server_id > 0 && !mongoc_cursor_set_hint(cursor, server_id)) { - phongo_throw_exception(PHONGO_ERROR_MONGOC_FAILED TSRMLS_CC, "%s", "Could not set cursor server_id"); - return false; + selected_server = mongoc_client_select_server(client, false, (zreadPreference ? phongo_read_preference_from_zval(zreadPreference TSRMLS_CC) : mongoc_client_get_read_prefs(client)), &error); + if (selected_server) { + selected_server_id = mongoc_server_description_id(selected_server); + bson_append_int32(opts, "serverId", -1, selected_server_id); + mongoc_server_description_destroy(selected_server); + } else { + /* Check for connection related exceptions */ + if (!EG(exception)) { + phongo_throw_exception_from_bson_error_t(&error TSRMLS_CC); + } + + bson_free(opts); + return false; + } } - if (!phongo_advance_cursor_and_check_for_error(cursor TSRMLS_CC)) { + if (!mongoc_client_command_with_opts(client, db, command->bson, phongo_read_preference_from_zval(zreadPreference TSRMLS_CC), opts, &reply, &error)) { + phongo_throw_exception_from_bson_error_t(&error TSRMLS_CC); + bson_free(opts); return false; } + bson_free(opts); + if (!return_value_used) { - mongoc_cursor_destroy(cursor); + bson_destroy(&reply); return true; } - if (bson_iter_init_find(&iter, mongoc_cursor_current(cursor), "cursor") && BSON_ITER_HOLDS_DOCUMENT(&iter)) { - mongoc_cursor_t *cmd_cursor; - - /* According to mongoc_cursor_new_from_command_reply(), the reply bson_t - * is ultimately destroyed on both success and failure. Use bson_copy() - * to create a writable copy of the const bson_t we fetched above. */ - cmd_cursor = mongoc_cursor_new_from_command_reply(client, bson_copy(mongoc_cursor_current(cursor)), mongoc_cursor_get_hint(cursor)); - mongoc_cursor_destroy(cursor); + /* According to mongoc_cursor_new_from_command_reply(), the reply bson_t + * is ultimately destroyed on both success and failure. */ + if (bson_iter_init_find(&iter, &reply, "cursor") && BSON_ITER_HOLDS_DOCUMENT(&iter)) { + cmd_cursor = mongoc_cursor_new_from_command_reply(client, &reply, selected_server_id); + } else { + bson_t *wrapped_reply = create_wrapped_command_envelope(db, &reply); - if (!phongo_advance_cursor_and_check_for_error(cmd_cursor TSRMLS_CC)) { - return false; - } + cmd_cursor = mongoc_cursor_new_from_command_reply(client, wrapped_reply, selected_server_id); + bson_destroy(&reply); + } - phongo_cursor_init_for_command(return_value, client, cmd_cursor, db, zcommand, zreadPreference TSRMLS_CC); - return true; + if (!phongo_advance_cursor_and_check_for_error(cmd_cursor TSRMLS_CC)) { + mongoc_cursor_destroy(cmd_cursor); + return false; } - phongo_cursor_init_for_command(return_value, client, cursor, db, zcommand, zreadPreference TSRMLS_CC); + phongo_cursor_init_for_command(return_value, client, cmd_cursor, db, zcommand, zreadPreference TSRMLS_CC); return true; } /* }}} */ @@ -1116,6 +1152,32 @@ static bool php_phongo_apply_options_to_uri(mongoc_uri_t *uri, bson_t *options T continue; } + + if (!strcasecmp(key, MONGOC_URI_GSSAPISERVICENAME)) { + bson_t unused, properties = BSON_INITIALIZER; + + if (mongoc_uri_get_mechanism_properties(uri, &unused)) { + phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "authMechanismProperties SERVICE_NAME already set, ignoring \"%s\"", key); + return false; + } + + if (!BSON_ITER_HOLDS_UTF8(&iter)) { + PHONGO_URI_INVALID_TYPE(iter, "string"); + return false; + } + + bson_append_utf8(&properties, "SERVICE_NAME", -1, bson_iter_utf8(&iter, NULL), -1); + + if (!mongoc_uri_set_mechanism_properties(uri, &properties)) { + phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Failed to parse \"%s\" URI option", key); + bson_destroy(&properties); + return false; + } + + bson_destroy(&properties); + + continue; + } } return true; diff --git a/src/libbson b/src/libbson index ca42366d1..b908d3173 160000 --- a/src/libbson +++ b/src/libbson @@ -1 +1 @@ -Subproject commit ca42366d16a5c1fb33aacdf9fefadf4e98d7aaa3 +Subproject commit b908d31737ef15f0317240d7c7652aad21532bfe diff --git a/src/libmongoc b/src/libmongoc index f09af3629..d5b8c42da 160000 --- a/src/libmongoc +++ b/src/libmongoc @@ -1 +1 @@ -Subproject commit f09af36295435576eb5d6323cbe3cc62f465a0b7 +Subproject commit d5b8c42da25201c8950c5df9bd258090951d88fd diff --git a/tests/apm/overview.phpt b/tests/apm/overview.phpt index d510eb086..07f45e062 100644 --- a/tests/apm/overview.phpt +++ b/tests/apm/overview.phpt @@ -48,7 +48,7 @@ object(MongoDB\Driver\Monitoring\CommandStartedEvent)#%d (%d) { ["command"]=> object(stdClass)#%d (%d) { ["drop"]=> - string(12) "apm_overview" + string(12) "apm_overview"%A } ["commandName"]=> string(4) "drop" @@ -105,20 +105,7 @@ object(MongoDB\Driver\Monitoring\CommandStartedEvent)#%d (%d) { object(stdClass)#%d (%d) { } ["ordered"]=> - bool(false) - ["documents"]=> - array(%d) { - [0]=> - object(stdClass)#%d (%d) { - ["decimal"]=> - int(12345678) - ["_id"]=> - object(MongoDB\BSON\ObjectId)#%d (%d) { - ["oid"]=> - string(24) "%s" - } - } - } + bool(false)%A } ["commandName"]=> string(6) "insert" @@ -160,7 +147,7 @@ object(MongoDB\Driver\Monitoring\CommandStartedEvent)#%d (%d) { string(12) "apm_overview" ["filter"]=> object(stdClass)#%d (%d) { - } + }%A } ["commandName"]=> string(4) "find" diff --git a/tests/bulk/bulkwrite-insert-002.phpt b/tests/bulk/bulkwrite-insert-002.phpt deleted file mode 100644 index 200dc2aa4..000000000 --- a/tests/bulk/bulkwrite-insert-002.phpt +++ /dev/null @@ -1,47 +0,0 @@ ---TEST-- -MongoDB\Driver\BulkWrite::insert() with legacy index (pre-2.6 server) ---SKIPIF-- - - ---FILE-- - ['a.b' => 1], - 'name' => 'a.b_1', - 'ns' => NS, -]; - -$bulk = new MongoDB\Driver\BulkWrite(); -$bulk->insert($legacyIndex); -$result = $manager->executeBulkWrite(DATABASE_NAME . '.system.indexes', $bulk); -printf("Created %d index(es)\n", $result->getInsertedCount()); - -$cursor = $manager->executeQuery(DATABASE_NAME . '.system.indexes', new MongoDB\Driver\Query(['name' => 'a.b_1'])); -var_dump($cursor->toArray()); - -?> -===DONE=== - ---EXPECTF-- -Created 1 index(es) -array(1) { - [0]=> - object(stdClass)#%d (%d) { - ["v"]=> - int(1) - ["name"]=> - string(5) "a.b_1" - ["key"]=> - object(stdClass)#%d (%d) { - ["a.b"]=> - int(1) - } - ["ns"]=> - string(%d) "%s" - } -} -===DONE=== diff --git a/tests/bulk/bulkwrite-insert-003.phpt b/tests/bulk/bulkwrite-insert-003.phpt deleted file mode 100644 index 84ec6f570..000000000 --- a/tests/bulk/bulkwrite-insert-003.phpt +++ /dev/null @@ -1,56 +0,0 @@ ---TEST-- -MongoDB\Driver\BulkWrite::insert() with legacy index false positive (2.6+ server) ---SKIPIF-- - - ---FILE-- - ['a' => 1], // Do not attempt to use dots in BSON keys - 'name' => 'a_1', - 'ns' => NS, -]; - -$bulk = new MongoDB\Driver\BulkWrite(); -$bulk->insert($legacyIndex); -$result = $manager->executeBulkWrite(NS, $bulk); -printf("Inserted %d document(s)\n", $result->getInsertedCount()); - -$cursor = $manager->executeQuery(NS, new MongoDB\Driver\Query(['name' => 'a_1'])); -var_dump($cursor->toArray()); - -?> -===DONE=== - ---EXPECTF-- -Inserted 1 document(s) -array(1) { - [0]=> - object(stdClass)#%d (%d) { - ["_id"]=> - object(MongoDB\BSON\ObjectId)#%d (%d) { - ["oid"]=> - string(24) "%x" - } - ["key"]=> - object(stdClass)#%d (%d) { - ["a"]=> - int(1) - } - ["name"]=> - string(3) "a_1" - ["ns"]=> - string(32) "phongo.bulk_bulkwrite_insert_003" - } -} -===DONE=== diff --git a/tests/bulk/bulkwrite-insert_error-004.phpt b/tests/bulk/bulkwrite-insert_error-004.phpt index 445afd34d..e967bda64 100644 --- a/tests/bulk/bulkwrite-insert_error-004.phpt +++ b/tests/bulk/bulkwrite-insert_error-004.phpt @@ -22,13 +22,13 @@ echo throws(function() use ($bulk) { ?> ===DONE=== ---EXPECT-- +--EXPECTF-- OK: Got MongoDB\Driver\Exception\InvalidArgumentException -legacy index document contains invalid key: empty key +%s contains invalid key: empty key OK: Got MongoDB\Driver\Exception\InvalidArgumentException -legacy index document contains invalid key: keys cannot begin with "$": "$x" +%s contains invalid key: keys cannot begin with "$": "$x" OK: Got MongoDB\Driver\Exception\InvalidArgumentException -legacy index document contains invalid key: corrupt BSON +%s contains invalid key: corrupt BSON ===DONE=== diff --git a/tests/cursor/cursor-destruct-001.phpt b/tests/cursor/cursor-destruct-001.phpt index 1d0c9bb26..f91eba6a7 100644 --- a/tests/cursor/cursor-destruct-001.phpt +++ b/tests/cursor/cursor-destruct-001.phpt @@ -11,7 +11,6 @@ function getNumOpenCursors(MongoDB\Driver\Manager $manager) { $cursor = $manager->executeCommand(DATABASE_NAME, new MongoDB\Driver\Command(array('serverStatus' => 1))); $result = current($cursor->toArray()); - if (isset($result->metrics->cursor->open->total)) { return $result->metrics->cursor->open->total; } diff --git a/tests/manager/manager-ctor-auth_mechanism-001.phpt b/tests/manager/manager-ctor-auth_mechanism-001.phpt index e00318d00..b75c7e1d6 100644 --- a/tests/manager/manager-ctor-auth_mechanism-001.phpt +++ b/tests/manager/manager-ctor-auth_mechanism-001.phpt @@ -4,8 +4,8 @@ MongoDB\Driver\Manager::__construct(): authMechanism option 'MONGODB-X509']], [null, ['authMechanism' => 'GSSAPI']], ]; diff --git a/tests/manager/manager-ctor-auth_mechanism-002.phpt b/tests/manager/manager-ctor-auth_mechanism-002.phpt index a9abcd20c..051364778 100644 --- a/tests/manager/manager-ctor-auth_mechanism-002.phpt +++ b/tests/manager/manager-ctor-auth_mechanism-002.phpt @@ -4,10 +4,10 @@ MongoDB\Driver\Manager::__construct(): authMechanismProperties option 'GSSAPI', 'authMechanismProperties' => ['CANONICALIZE_HOST_NAME' => 'true', 'SERVICE_NAME' => 'foo', 'SERVICE_REALM' => 'bar']]], // Options are case-insensitive - ['mongodb://127.0.0.1/?authMechanism=GSSAPI&authMechanismProperties=canonicalize_host_name:TRUE,service_name:foo,service_realm:bar', []], + ['mongodb://username@127.0.0.1/?authMechanism=GSSAPI&authMechanismProperties=canonicalize_host_name:TRUE,service_name:foo,service_realm:bar', []], [null, ['authMechanism' => 'GSSAPI', 'authMechanismProperties' => ['canonicalize_host_name' => 'TRUE', 'service_name' => 'foo', 'service_realm' => 'bar']]], // Boolean true "CANONICALIZE_HOST_NAME" value is converted to "true" [null, ['authMechanism' => 'GSSAPI', 'authMechanismProperties' => ['canonicalize_host_name' => true]]], diff --git a/tests/manager/manager-ctor-read_preference-error-001.phpt b/tests/manager/manager-ctor-read_preference-error-001.phpt index fc48913e1..8273d3d79 100644 --- a/tests/manager/manager-ctor-read_preference-error-001.phpt +++ b/tests/manager/manager-ctor-read_preference-error-001.phpt @@ -48,7 +48,7 @@ echo throws(function() { --EXPECT-- OK: Got MongoDB\Driver\Exception\InvalidArgumentException -Failed to parse MongoDB URI: 'mongodb://127.0.0.1/?readPreference=1'. Unsupported readPreference value [readPreference=1].. +Failed to parse MongoDB URI: 'mongodb://127.0.0.1/?readPreference=1'. Unsupported readPreference value [readPreference=1]. OK: Got MongoDB\Driver\Exception\InvalidArgumentException Failed to parse MongoDB URI: 'mongodb://127.0.0.1/?readPreference=secondary&readPreferenceTags=invalid'. Unknown option or value for 'readPreferenceTags=invalid'. OK: Got MongoDB\Driver\Exception\InvalidArgumentException diff --git a/tests/manager/manager-ctor-write_concern-error-005.phpt b/tests/manager/manager-ctor-write_concern-error-005.phpt index 82e79bf6f..aa5458fdb 100644 --- a/tests/manager/manager-ctor-write_concern-error-005.phpt +++ b/tests/manager/manager-ctor-write_concern-error-005.phpt @@ -58,9 +58,9 @@ Failed to parse MongoDB URI: 'mongodb://127.0.0.1/?journal=invalid'. Unknown opt OK: Got MongoDB\Driver\Exception\InvalidArgumentException Expected boolean for "journal" URI option, string given OK: Got MongoDB\Driver\Exception\InvalidArgumentException -Failed to parse MongoDB URI: 'mongodb://127.0.0.1/?w=-1&journal=true'. Invalid writeConcern. +Failed to parse MongoDB URI: 'mongodb://127.0.0.1/?w=-1&journal=true'. Journal conflicts with w value [w=-1]. OK: Got MongoDB\Driver\Exception\InvalidArgumentException -Failed to parse MongoDB URI: 'mongodb://127.0.0.1/?w=0&journal=true'. Invalid writeConcern. +Failed to parse MongoDB URI: 'mongodb://127.0.0.1/?w=0&journal=true'. Journal conflicts with w value [w=0]. OK: Got MongoDB\Driver\Exception\InvalidArgumentException Journal conflicts with w value: -1 OK: Got MongoDB\Driver\Exception\InvalidArgumentException diff --git a/tests/manager/manager-ctor_error-002.phpt b/tests/manager/manager-ctor_error-002.phpt index 81157c30b..e805564d5 100644 --- a/tests/manager/manager-ctor_error-002.phpt +++ b/tests/manager/manager-ctor_error-002.phpt @@ -14,5 +14,5 @@ echo throws(function() { --EXPECT-- OK: Got MongoDB\Driver\Exception\InvalidArgumentException -Failed to parse MongoDB URI: 'not a valid connection string'. Invalid URI Schema, expecting 'mongodb://'. +Failed to parse MongoDB URI: 'not a valid connection string'. Invalid URI Schema, expecting 'mongodb://' or 'mongodb+srv://'. ===DONE=== diff --git a/tests/writeConcern/writeconcern-isdefault-001.phpt b/tests/writeConcern/writeconcern-isdefault-001.phpt index a4426c2dd..515c64516 100644 --- a/tests/writeConcern/writeconcern-isdefault-001.phpt +++ b/tests/writeConcern/writeconcern-isdefault-001.phpt @@ -14,8 +14,8 @@ $tests = [ new MongoDB\Driver\WriteConcern(MongoDB\Driver\WriteConcern::MAJORITY), // mongoc_uri_parse_option() ignores empty string for w (new MongoDB\Driver\Manager('mongodb://127.0.0.1/?w='))->getWriteConcern(), - // Cannot test "w=-3" since libmongoc URI parsing expects integers >= -2 - (new MongoDB\Driver\Manager('mongodb://127.0.0.1/?w=-2'))->getWriteConcern(), + // Cannot test "w=-3" since libmongoc URI parsing expects integers >= -1 + // Cannot test "w=-2" since libmongoc URI parsing expects integers >= -1, and throws an error otherwise (new MongoDB\Driver\Manager('mongodb://127.0.0.1/?w=-1'))->getWriteConcern(), (new MongoDB\Driver\Manager('mongodb://127.0.0.1/?w=0'))->getWriteConcern(), (new MongoDB\Driver\Manager('mongodb://127.0.0.1/?w=1'))->getWriteConcern(), @@ -50,7 +50,6 @@ bool(false) bool(false) bool(false) bool(true) -bool(true) bool(false) bool(false) bool(false) diff --git a/tests/writeResult/writeresult-getmodifiedcount-003.phpt b/tests/writeResult/writeresult-getmodifiedcount-003.phpt deleted file mode 100644 index daa2da9bf..000000000 --- a/tests/writeResult/writeresult-getmodifiedcount-003.phpt +++ /dev/null @@ -1,28 +0,0 @@ ---TEST-- -MongoDB\Driver\WriteResult::getModifiedCount() not available for legacy writes ---SKIPIF-- - - ---FILE-- -insert(['x' => 1]); -$bulk->update(['x' => 1], ['$set' => ['y' => 3]]); -$bulk->update(['x' => 2], ['$set' => ['y' => 1]], ['upsert' => true]); -$bulk->update(['x' => 3], ['$set' => ['y' => 2]], ['upsert' => true]); -$bulk->delete(['x' => 1]); - -$result = $manager->executeBulkWrite(NS, $bulk); - -var_dump($result->getModifiedCount()); - -?> -===DONE=== - ---EXPECT-- -NULL -===DONE===