From 787f301143e5cb8fa7c1f6e7b5c95fc00faac0b0 Mon Sep 17 00:00:00 2001 From: Jeremy Mikola Date: Wed, 15 Jan 2025 14:01:22 -0500 Subject: [PATCH 1/7] PHPC-2499: Update to libmongoc 1.29.2 (#1766) * Install Python 3.13 for drivers-evergreen-tools GH action Related to mongodb/mongo-php-library#1564 --- .github/workflows/tests.yml | 4 ++++ sbom.json | 16 ++++++++-------- src/LIBMONGOC_VERSION_CURRENT | 2 +- src/libmongoc | 2 +- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 56eb5b6ea..8fb2368e4 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -53,6 +53,10 @@ jobs: with: submodules: true + - uses: actions/setup-python@v5 + with: + python-version: '3.13' + - id: setup-mongodb uses: mongodb-labs/drivers-evergreen-tools@master with: diff --git a/sbom.json b/sbom.json index fb98f7605..7ed391e81 100644 --- a/sbom.json +++ b/sbom.json @@ -19,22 +19,22 @@ "version": "1.12.0" }, { - "bom-ref": "pkg:github/mongodb/mongo-c-driver@1.29.0", + "bom-ref": "pkg:github/mongodb/mongo-c-driver@1.29.2", "externalReferences": [ { "type": "distribution", - "url": "https://github.com/mongodb/mongo-c-driver/archive/refs/tags/1.29.0.tar.gz" + "url": "https://github.com/mongodb/mongo-c-driver/archive/refs/tags/1.29.2.tar.gz" }, { "type": "website", - "url": "https://github.com/mongodb/mongo-c-driver/tree/1.29.0" + "url": "https://github.com/mongodb/mongo-c-driver/tree/1.29.2" } ], "group": "mongodb", "name": "mongo-c-driver", - "purl": "pkg:github/mongodb/mongo-c-driver@1.29.0", + "purl": "pkg:github/mongodb/mongo-c-driver@1.29.2", "type": "library", - "version": "1.29.0" + "version": "1.29.2" } ], "dependencies": [ @@ -42,11 +42,11 @@ "ref": "pkg:github/mongodb/libmongocrypt@1.12.0" }, { - "ref": "pkg:github/mongodb/mongo-c-driver@1.29.0" + "ref": "pkg:github/mongodb/mongo-c-driver@1.29.2" } ], "metadata": { - "timestamp": "2024-11-12T18:00:38.546484+00:00", + "timestamp": "2025-01-14T14:24:24.250261+00:00", "tools": [ { "externalReferences": [ @@ -90,7 +90,7 @@ ] }, "serialNumber": "urn:uuid:acb30d08-ee47-4ff0-b301-d66ef1f54082", - "version": 7, + "version": 8, "$schema": "http://cyclonedx.org/schema/bom-1.5.schema.json", "bomFormat": "CycloneDX", "specVersion": "1.5", diff --git a/src/LIBMONGOC_VERSION_CURRENT b/src/LIBMONGOC_VERSION_CURRENT index 5e57fb895..412114252 100644 --- a/src/LIBMONGOC_VERSION_CURRENT +++ b/src/LIBMONGOC_VERSION_CURRENT @@ -1 +1 @@ -1.29.0 +1.29.2 diff --git a/src/libmongoc b/src/libmongoc index fc82e03cb..48011c65d 160000 --- a/src/libmongoc +++ b/src/libmongoc @@ -1 +1 @@ -Subproject commit fc82e03cbea13abf276b5abb3736249e97c7ee0f +Subproject commit 48011c65d759bc288a02a583c378a224c1141bbb From 2585be41bac879c2c278ba469025e2253a8cb7f9 Mon Sep 17 00:00:00 2001 From: Jeremy Mikola Date: Wed, 29 Jan 2025 11:39:15 -0500 Subject: [PATCH 2/7] PHPC-2496: WriteException stub should inherit ServerException (#1769) --- src/MongoDB/Exception/WriteException.stub.php | 2 +- src/MongoDB/Exception/WriteException_arginfo.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/MongoDB/Exception/WriteException.stub.php b/src/MongoDB/Exception/WriteException.stub.php index 4372e933a..9ee7bfc26 100644 --- a/src/MongoDB/Exception/WriteException.stub.php +++ b/src/MongoDB/Exception/WriteException.stub.php @@ -8,7 +8,7 @@ namespace MongoDB\Driver\Exception; /** @deprecated use MongoDB\Driver\Exception\BulkWriteException instead */ -abstract class WriteException extends RuntimeException +abstract class WriteException extends ServerException { /** @var \MongoDB\Driver\WriteResult */ protected $writeResult; diff --git a/src/MongoDB/Exception/WriteException_arginfo.h b/src/MongoDB/Exception/WriteException_arginfo.h index 9c3e9f43d..e373c6bfe 100644 --- a/src/MongoDB/Exception/WriteException_arginfo.h +++ b/src/MongoDB/Exception/WriteException_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: bf7229dbad041a8fe73af62d1961700783a933e3 */ + * Stub hash: d68a9b6bb6ba6a1222689ffe95c58ce91b3a6704 */ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_MongoDB_Driver_Exception_WriteException_getWriteResult, 0, 0, MongoDB\\Driver\\WriteResult, 0) ZEND_END_ARG_INFO() @@ -13,12 +13,12 @@ static const zend_function_entry class_MongoDB_Driver_Exception_WriteException_m ZEND_FE_END }; -static zend_class_entry *register_class_MongoDB_Driver_Exception_WriteException(zend_class_entry *class_entry_MongoDB_Driver_Exception_RuntimeException) +static zend_class_entry *register_class_MongoDB_Driver_Exception_WriteException(zend_class_entry *class_entry_MongoDB_Driver_Exception_ServerException) { zend_class_entry ce, *class_entry; INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Exception", "WriteException", class_MongoDB_Driver_Exception_WriteException_methods); - class_entry = zend_register_internal_class_ex(&ce, class_entry_MongoDB_Driver_Exception_RuntimeException); + class_entry = zend_register_internal_class_ex(&ce, class_entry_MongoDB_Driver_Exception_ServerException); class_entry->ce_flags |= ZEND_ACC_ABSTRACT|ZEND_ACC_DEPRECATED; zval property_writeResult_default_value; From 2b2e0be061aa89950e8da617c4eb8f5bd60bb7b8 Mon Sep 17 00:00:00 2001 From: Jeremy Mikola Date: Wed, 29 Jan 2025 11:44:36 -0500 Subject: [PATCH 3/7] PHPC-2477: Remove unused libmongoc and libbson constants (#1768) * PHPC-2477: BSON_HAVE_ATOMIC constants are obsolete CDRIVER-4124 removed BSON_HAVE_ATOMIC_32_ADD_AND_FETCH and BSON_HAVE_ATOMIC_64_ADD_AND_FETCH * PHPC-2477: BSON_PTHREAD_ONCE_INIT_NEEDS_BRACES is obsolete CDRIVER-2694 removed BSON_PTHREAD_ONCE_INIT_NEEDS_BRACES * PHPC-2477: BSON_HAVE_REALLOCF is obsolete BSON_HAVE_REALLOCF was no longer used when libbson was vendored in CDRIVER-2416 * PHPC-2477: BSON_HAVE_SYSCALL_TID is obsolete CDRIVER-2771 removed outstanding references to BSON_HAVE_SYSCALL_TID * PHPC-2477: BSON_NEEDS_SET_OUTPUT_FORMAT is obsolete * PHPC-2477: BSON_HAVE_DECIMAL128 is obsolete * PHPC-2477: BSON_HAVE_ARC4RANDOM_BUF is obsolete * PHPC-2477: MONGOC_ENABLE_SASL_GSSAPI is obsolete CDRIVER-2654 removed MONGOC_ENABLE_SASL_GSSAPI. PHPC-2312 removed it from Autotools, but it was left behind in config.w32. * PHPC-2477: MONGOC_HAVE_WEAK_SYMBOLS is obsolete CDRIVER-2600 removed MONGOC_HAVE_WEAK_SYMBOLS --- config.m4 | 2 - config.w32 | 16 +---- scripts/autotools/libbson/CheckAtomics.m4 | 23 ------- scripts/autotools/libbson/FindDependencies.m4 | 67 ------------------- scripts/autotools/libmongoc/WeakSymbols.m4 | 9 --- 5 files changed, 1 insertion(+), 116 deletions(-) delete mode 100644 scripts/autotools/libbson/CheckAtomics.m4 delete mode 100644 scripts/autotools/libmongoc/WeakSymbols.m4 diff --git a/config.m4 b/config.m4 index 28998f5e8..57f2c42c5 100644 --- a/config.m4 +++ b/config.m4 @@ -338,7 +338,6 @@ if test "$PHP_MONGODB" != "no"; then m4_include(PHP_MONGODB_BASEDIR/scripts/autotools/CheckHost.m4) m4_include(PHP_MONGODB_BASEDIR/scripts/autotools/PlatformFlags.m4) - m4_include(PHP_MONGODB_BASEDIR/scripts/autotools/libbson/CheckAtomics.m4) m4_include(PHP_MONGODB_BASEDIR/scripts/autotools/libbson/CheckHeaders.m4) m4_include(PHP_MONGODB_BASEDIR/scripts/autotools/libbson/Endian.m4) m4_include(PHP_MONGODB_BASEDIR/scripts/autotools/libbson/FindDependencies.m4) @@ -352,7 +351,6 @@ if test "$PHP_MONGODB" != "no"; then m4_include(PHP_MONGODB_BASEDIR/scripts/autotools/libmongoc/Endian.m4) m4_include(PHP_MONGODB_BASEDIR/scripts/autotools/libmongoc/FindDependencies.m4) m4_include(PHP_MONGODB_BASEDIR/scripts/autotools/libmongoc/Versions.m4) - m4_include(PHP_MONGODB_BASEDIR/scripts/autotools/libmongoc/WeakSymbols.m4) dnl This include modifies the value of $PHP_MONGODB_CLIENT_SIDE_ENCRYPTION to "yes" dnl or "no" depending on whether dependencies for libmongocrypt are fulfilled diff --git a/config.w32 b/config.w32 index dbded6599..91199a87b 100644 --- a/config.w32 +++ b/config.w32 @@ -130,28 +130,16 @@ if (PHP_MONGODB != "no") { BSON_OS: 2, BSON_HAVE_STDBOOL_H: 0, BSON_HAVE_STRINGS_H: 0, - BSON_HAVE_ATOMIC_32_ADD_AND_FETCH: 0, - BSON_HAVE_ATOMIC_64_ADD_AND_FETCH: 0, - BSON_PTHREAD_ONCE_INIT_NEEDS_BRACES: 0, BSON_HAVE_CLOCK_GETTIME: 0, BSON_HAVE_STRNLEN: 0, BSON_HAVE_SNPRINTF: 0, BSON_HAVE_STRLCPY: 0, - BSON_HAVE_REALLOCF: 0, - BSON_NEEDS_SET_OUTPUT_FORMAT: 0, BSON_HAVE_TIMESPEC: 0, BSON_EXTRA_ALIGN: 0, - BSON_HAVE_SYSCALL_TID: 0, - BSON_HAVE_DECIMAL128: 0, BSON_HAVE_GMTIME_R: 0, - BSON_HAVE_RAND_R: 0, - BSON_HAVE_ARC4RANDOM_BUF: 0 + BSON_HAVE_RAND_R: 0 }; - if (CHECK_FUNC_IN_HEADER("stdio.h", "_set_output_format")) { - bson_opts.BSON_NEEDS_SET_OUTPUT_FORMAT = 1; - } - mongodb_generate_header( configure_module_dirname + "/src/libmongoc/src/libbson/src/bson/bson-config.h.in", configure_module_dirname + "/src/libmongoc/src/libbson/src/bson/bson-config.h", @@ -187,7 +175,6 @@ if (PHP_MONGODB != "no") { MONGOC_ENABLE_MONGODB_AWS_AUTH: 0, MONGOC_ENABLE_SASL: 0, MONGOC_ENABLE_SASL_CYRUS: 0, - MONGOC_ENABLE_SASL_GSSAPI: 0, MONGOC_ENABLE_SASL_SSPI: 0, MONGOC_ENABLE_SRV: 0, MONGOC_ENABLE_RDTSCP: 0, @@ -196,7 +183,6 @@ if (PHP_MONGODB != "no") { MONGOC_HAVE_SASL_CLIENT_DONE: 0, MONGOC_HAVE_SCHED_GETCPU: 0, MONGOC_HAVE_SOCKLEN: 1, - MONGOC_HAVE_WEAK_SYMBOLS: 0, MONGOC_NO_AUTOMATIC_GLOBALS: 1, MONGOC_SOCKET_ARG2: "struct sockaddr", MONGOC_SOCKET_ARG3: "socklen_t", diff --git a/scripts/autotools/libbson/CheckAtomics.m4 b/scripts/autotools/libbson/CheckAtomics.m4 deleted file mode 100644 index 3071e36df..000000000 --- a/scripts/autotools/libbson/CheckAtomics.m4 +++ /dev/null @@ -1,23 +0,0 @@ -AC_LANG_PUSH([C]) -AC_MSG_CHECKING([for __sync_add_and_fetch_4]) -AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], - [[int32_t v = 1; return __sync_add_and_fetch_4 (&v, (int32_t)10);]])], - [AC_MSG_RESULT(yes) - have_sync_add_and_fetch_4=yes], - [AC_MSG_RESULT(no) - have_sync_add_and_fetch_4=no]) -AS_IF([test "$have_sync_add_and_fetch_4" = "yes"], - [AC_SUBST(BSON_HAVE_ATOMIC_32_ADD_AND_FETCH, 1)], - [AC_SUBST(BSON_HAVE_ATOMIC_32_ADD_AND_FETCH, 0)]) - -AC_MSG_CHECKING([for __sync_add_and_fetch_8]) -AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], - [[int64_t v; return __sync_add_and_fetch_8 (&v, (int64_t)10);]])], - [AC_MSG_RESULT(yes) - have_sync_add_and_fetch_8=yes], - [AC_MSG_RESULT(no) - have_sync_add_and_fetch_8=no]) -AS_IF([test "$have_sync_add_and_fetch_8" = "yes"], - [AC_SUBST(BSON_HAVE_ATOMIC_64_ADD_AND_FETCH, 1)], - [AC_SUBST(BSON_HAVE_ATOMIC_64_ADD_AND_FETCH, 0)]) -AC_LANG_POP([C]) diff --git a/scripts/autotools/libbson/FindDependencies.m4 b/scripts/autotools/libbson/FindDependencies.m4 index f365f6c21..2472e0a1b 100644 --- a/scripts/autotools/libbson/FindDependencies.m4 +++ b/scripts/autotools/libbson/FindDependencies.m4 @@ -13,46 +13,6 @@ if test "$bson_cv_have_strnlen" = yes; then AC_SUBST(BSON_HAVE_STRNLEN, 1) fi -# Check for reallocf() (BSD/Darwin) -AC_SUBST(BSON_HAVE_REALLOCF, 0) -AC_CACHE_CHECK([for reallocf], - bson_cv_have_reallocf, - [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ -#include -int reallocf () { return 0; } -]])], - [bson_cv_have_reallocf=no], - [bson_cv_have_reallocf=yes])]) -if test "$bson_cv_have_reallocf" = yes; then - AC_SUBST(BSON_HAVE_REALLOCF, 1) -fi - -# Check for syscall() -AC_SUBST(BSON_HAVE_SYSCALL_TID, 0) -AC_CACHE_CHECK([for syscall], - bson_cv_have_syscall_tid, - [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ -#include -#include -int syscall () { return 0; } -]])], - [bson_cv_have_syscall_tid=no], - [bson_cv_have_syscall_tid=yes])]) -if test "$bson_cv_have_syscall_tid" = yes -a "$os_darwin" != "yes"; then - AC_CACHE_CHECK([for SYS_gettid], - bson_cv_have_sys_gettid_tid, - [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ -#include -#include -int gettid () { return SYS_gettid; } - ]])], - [bson_cv_have_sys_gettid_tid=yes], - [bson_cv_have_sys_gettid_tid=no])]) - if test "$bson_cv_have_sys_gettid_tid" = yes; then - AC_SUBST(BSON_HAVE_SYSCALL_TID, 1) - fi -fi - # Check for snprintf() AC_SUBST(BSON_HAVE_SNPRINTF, 0) AC_CHECK_FUNC(snprintf, [AC_SUBST(BSON_HAVE_SNPRINTF, 1)]) @@ -79,10 +39,6 @@ AC_CHECK_FUNC(gmtime_r, [AC_SUBST(BSON_HAVE_GMTIME_R, 1)]) AC_SUBST(BSON_HAVE_RAND_R, 0) AC_CHECK_FUNC(rand_r, [AC_SUBST(BSON_HAVE_RAND_R, 1)]) -# Check for arc4random_buf() -AC_SUBST(BSON_HAVE_ARC4RANDOM_BUF, 0) -AC_CHECK_FUNC(arc4random_buf, [AC_SUBST(BSON_HAVE_ARC4RANDOM_BUF, 1)]) - # Check for pthreads. We might need to make this better to handle mingw, # but I actually think it is okay to just check for it even though we will # use win32 primatives. @@ -96,26 +52,3 @@ AX_PTHREAD([ ],[ AC_MSG_ERROR([libbson requires pthreads on non-Windows platforms.]) ]) - - -# The following is borrowed from the guile configure script. -# -# On past versions of Solaris, believe 8 through 10 at least, you -# had to write "pthread_once_t foo = { PTHREAD_ONCE_INIT };". -# This is contrary to POSIX: -# http://www.opengroup.org/onlinepubs/000095399/functions/pthread_once.html -# Check here if this style is required. -# -# glibc (2.3.6 at least) works both with or without braces, so the -# test checks whether it works without. -# -AC_SUBST(BSON_PTHREAD_ONCE_INIT_NEEDS_BRACES, 0) -AC_CACHE_CHECK([whether PTHREAD_ONCE_INIT needs braces], - bson_cv_need_braces_on_pthread_once_init, - [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include - pthread_once_t foo = PTHREAD_ONCE_INIT;]])], - [bson_cv_need_braces_on_pthread_once_init=no], - [bson_cv_need_braces_on_pthread_once_init=yes])]) -if test "$bson_cv_need_braces_on_pthread_once_init" = yes; then - AC_SUBST(BSON_PTHREAD_ONCE_INIT_NEEDS_BRACES, 1) -fi diff --git a/scripts/autotools/libmongoc/WeakSymbols.m4 b/scripts/autotools/libmongoc/WeakSymbols.m4 deleted file mode 100644 index 1a54a4fe7..000000000 --- a/scripts/autotools/libmongoc/WeakSymbols.m4 +++ /dev/null @@ -1,9 +0,0 @@ -AC_MSG_CHECKING(if weak symbols are supported) -AC_LINK_IFELSE([AC_LANG_PROGRAM([[ -__attribute__((weak)) void __dummy(void *x) { } -void f(void *x) { __dummy(x); } -]], [[ ]] -)], -[AC_MSG_RESULT(yes) -AC_SUBST(MONGOC_HAVE_WEAK_SYMBOLS, 1)], -[AC_MSG_RESULT(no)]) From 7590fae661ad41f49326b3a43735c0f2a4c5a0e2 Mon Sep 17 00:00:00 2001 From: Jeremy Mikola Date: Wed, 29 Jan 2025 14:38:03 -0500 Subject: [PATCH 4/7] PHPC-2502: Remove XFAIL in server-executeQuery-012.phpt (#1772) The corresponding CDRIVER ticket was fixed a while back, and included in the submodule bump for PHPC 1.13. --- tests/server/server-executeQuery-012.phpt | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/server/server-executeQuery-012.phpt b/tests/server/server-executeQuery-012.phpt index f67a06336..c324f0757 100644 --- a/tests/server/server-executeQuery-012.phpt +++ b/tests/server/server-executeQuery-012.phpt @@ -1,7 +1,5 @@ --TEST-- MongoDB\Driver\Server::executeQuery() pins transaction to server ---XFAIL-- -_mongoc_cursor_fetch_stream segfault (CDRIVER-4290) --SKIPIF-- From 754e934312a77f88274c9870ded11924b37c0532 Mon Sep 17 00:00:00 2001 From: Jeremy Mikola Date: Wed, 29 Jan 2025 16:25:12 -0500 Subject: [PATCH 5/7] PHPC-2489: Deprecate passing WriteConcern and ReadPreference objects to execute methods (#1770) * Prefer writeConcern and readPreference options for execute methods * Correctly use Server method in server-executeQuery-010.phpt The original test incorrectly called the Manager method. This dates back to 87fbd007f0ee6348ed218c872c135e9a52e9c282. --- src/phongo_util.c | 2 ++ tests/bulk/write-0002.phpt | 2 +- .../manager/manager-executeBulkWrite-015.phpt | 23 ++++++++++++++++++ .../manager-executeBulkWrite_error-003.phpt | 2 +- tests/manager/manager-executeCommand-003.phpt | 4 ++++ tests/manager/manager-executeQuery-004.phpt | 4 ++++ tests/readPreference/bug0146-001.phpt | 2 +- tests/replicaset/bug0155.phpt | 2 +- tests/replicaset/readconcern-001.phpt | 2 +- tests/replicaset/writeconcernerror-001.phpt | 2 +- tests/replicaset/writeconcernerror-002.phpt | 2 +- .../replicaset/writeresult-getserver-001.phpt | 2 +- .../replicaset/writeresult-getserver-002.phpt | 2 +- tests/server/server-executeBulkWrite-002.phpt | 2 +- tests/server/server-executeBulkWrite-003.phpt | 2 +- tests/server/server-executeBulkWrite-004.phpt | 2 +- tests/server/server-executeBulkWrite-005.phpt | 2 +- tests/server/server-executeBulkWrite-010.phpt | 24 +++++++++++++++++++ tests/server/server-executeCommand-002.phpt | 4 ++-- tests/server/server-executeCommand-003.phpt | 2 +- tests/server/server-executeCommand-005.phpt | 4 ++++ tests/server/server-executeQuery-006.phpt | 4 ++-- tests/server/server-executeQuery-008.phpt | 4 ++-- tests/server/server-executeQuery-010.phpt | 8 +++++-- tests/standalone/bug0545.phpt | 4 ++-- tests/standalone/manager-as-singleton.phpt | 2 +- tests/standalone/write-error-001.phpt | 2 +- .../writeresult-isacknowledged-003.phpt | 2 +- .../writeconcernerror-debug-001.phpt | 2 +- .../writeconcernerror-getcode-001.phpt | 2 +- .../writeconcernerror-getmessage-001.phpt | 2 +- tests/writeResult/writeresult-debug-002.phpt | 2 +- .../writeresult-getdeletedcount-002.phpt | 2 +- .../writeresult-getinsertedcount-002.phpt | 2 +- .../writeresult-getmatchedcount-002.phpt | 2 +- .../writeresult-getmodifiedcount-002.phpt | 2 +- .../writeresult-getupsertedcount-002.phpt | 2 +- .../writeresult-getwriteconcernerror-001.phpt | 2 +- .../writeresult-isacknowledged-001.phpt | 2 +- 39 files changed, 103 insertions(+), 38 deletions(-) create mode 100644 tests/manager/manager-executeBulkWrite-015.phpt create mode 100644 tests/server/server-executeBulkWrite-010.phpt diff --git a/src/phongo_util.c b/src/phongo_util.c index 3088c15bf..3c3c639fd 100644 --- a/src/phongo_util.c +++ b/src/phongo_util.c @@ -92,6 +92,8 @@ zval* php_phongo_prep_legacy_option(zval* options, const char* key, bool* alloca Z_ADDREF_P(options); *allocated = true; + php_error_docref(NULL, E_DEPRECATED, "Passing the \"%s\" option directly is deprecated and will be removed in ext-mongodb 2.0", key); + return new_options; } diff --git a/tests/bulk/write-0002.phpt b/tests/bulk/write-0002.phpt index 44a3b47a1..0ccdf53d9 100644 --- a/tests/bulk/write-0002.phpt +++ b/tests/bulk/write-0002.phpt @@ -21,7 +21,7 @@ $w = 1; $wtimeout = 1000; $writeConcern = new \MongoDB\Driver\WriteConcern($w, $wtimeout); var_dump($insertBulk); -$result = $manager->executeBulkWrite(NS, $insertBulk, $writeConcern); +$result = $manager->executeBulkWrite(NS, $insertBulk, ['writeConcern' => $writeConcern]); var_dump($insertBulk); assert($result instanceof \MongoDB\Driver\WriteResult); diff --git a/tests/manager/manager-executeBulkWrite-015.phpt b/tests/manager/manager-executeBulkWrite-015.phpt new file mode 100644 index 000000000..4f6754820 --- /dev/null +++ b/tests/manager/manager-executeBulkWrite-015.phpt @@ -0,0 +1,23 @@ +--TEST-- +MongoDB\Driver\Manager::executeBulkWrite() explicit WriteConcern argument is deprecated +--SKIPIF-- + + + +--FILE-- +insert(['_id' => 1]); +$manager->executeBulkWrite(NS, $bulk, new MongoDB\Driver\WriteConcern(0)); + +?> +===DONE=== + +--EXPECTF-- +Deprecated: MongoDB\Driver\Manager::executeBulkWrite(): Passing the "writeConcern" option directly is deprecated and will be removed in ext-mongodb 2.0%s +===DONE=== diff --git a/tests/manager/manager-executeBulkWrite_error-003.phpt b/tests/manager/manager-executeBulkWrite_error-003.phpt index dd92c2590..613479a72 100644 --- a/tests/manager/manager-executeBulkWrite_error-003.phpt +++ b/tests/manager/manager-executeBulkWrite_error-003.phpt @@ -14,7 +14,7 @@ $bulk = new MongoDB\Driver\BulkWrite(); $bulk->insert(array('_id' => 1, 'x' => 1)); try { - $manager->executeBulkWrite(NS, $bulk, new MongoDB\Driver\WriteConcern(30)); + $manager->executeBulkWrite(NS, $bulk, ['writeConcern' => new MongoDB\Driver\WriteConcern(30)]); } catch (MongoDB\Driver\Exception\BulkWriteException $e) { printf("BulkWriteException: %s\n", $e->getMessage()); diff --git a/tests/manager/manager-executeCommand-003.phpt b/tests/manager/manager-executeCommand-003.phpt index 289d564af..788a4896b 100644 --- a/tests/manager/manager-executeCommand-003.phpt +++ b/tests/manager/manager-executeCommand-003.phpt @@ -32,10 +32,14 @@ echo "is_secondary: ", $cursor->getServer()->isSecondary() ? 'true' : 'false', " --EXPECTF-- Testing primary: + +Deprecated: MongoDB\Driver\Manager::executeCommand(): Passing the "readPreference" option directly is deprecated and will be removed in ext-mongodb 2.0%s is_primary: true is_secondary: false Testing secondary: + +Deprecated: MongoDB\Driver\Manager::executeCommand(): Passing the "readPreference" option directly is deprecated and will be removed in ext-mongodb 2.0%s is_primary: false is_secondary: true diff --git a/tests/manager/manager-executeQuery-004.phpt b/tests/manager/manager-executeQuery-004.phpt index 80e8a243d..362a9fc85 100644 --- a/tests/manager/manager-executeQuery-004.phpt +++ b/tests/manager/manager-executeQuery-004.phpt @@ -37,10 +37,14 @@ echo "is_secondary: ", $cursor->getServer()->isSecondary() ? 'true' : 'false', " --EXPECTF-- Testing primary: + +Deprecated: MongoDB\Driver\Manager::executeQuery(): Passing the "readPreference" option directly is deprecated and will be removed in ext-mongodb 2.0%s is_primary: true is_secondary: false Testing secondary: + +Deprecated: MongoDB\Driver\Manager::executeQuery(): Passing the "readPreference" option directly is deprecated and will be removed in ext-mongodb 2.0%s is_primary: false is_secondary: true diff --git a/tests/readPreference/bug0146-001.phpt b/tests/readPreference/bug0146-001.phpt index 563e01700..a4433867a 100644 --- a/tests/readPreference/bug0146-001.phpt +++ b/tests/readPreference/bug0146-001.phpt @@ -26,7 +26,7 @@ $rps = [ foreach($rps as $r) { $rp = new MongoDB\Driver\ReadPreference($r); - $cursor = $manager->executeQuery(NS, new MongoDB\Driver\Query(array("my" => "query")), $rp); + $cursor = $manager->executeQuery(NS, new MongoDB\Driver\Query(['my' => 'query']), ['readPreference' => $rp]); var_dump($cursor); } diff --git a/tests/replicaset/bug0155.phpt b/tests/replicaset/bug0155.phpt index 347e4b4f0..36d7ad78e 100644 --- a/tests/replicaset/bug0155.phpt +++ b/tests/replicaset/bug0155.phpt @@ -15,7 +15,7 @@ $bulk = new MongoDB\Driver\BulkWrite(); $bulk->insert(array('example' => 'document')); try { - $manager->executeBulkWrite(NS, $bulk, $wc); + $manager->executeBulkWrite(NS, $bulk, ['writeConcern' => $wc]); } catch(MongoDB\Driver\Exception\BulkWriteException $e) { var_dump($e->getWriteResult()->getWriteConcernError()); } diff --git a/tests/replicaset/readconcern-001.phpt b/tests/replicaset/readconcern-001.phpt index 2c699d1ec..2840535f4 100644 --- a/tests/replicaset/readconcern-001.phpt +++ b/tests/replicaset/readconcern-001.phpt @@ -15,7 +15,7 @@ $wc = new MongoDB\Driver\WriteConcern(MongoDB\Driver\WriteConcern::MAJORITY); $bulk = new MongoDB\Driver\BulkWrite(); $bulk->insert(['_id' => 1, 'x' => 1]); $bulk->insert(['_id' => 2, 'x' => 2]); -$manager->executeBulkWrite(NS, $bulk, $wc); +$manager->executeBulkWrite(NS, $bulk, ['writeConcern' => $wc]); $rc = new MongoDB\Driver\ReadConcern(MongoDB\Driver\ReadConcern::LOCAL); $query = new MongoDB\Driver\Query(['x' => 2], ['readConcern' => $rc]); diff --git a/tests/replicaset/writeconcernerror-001.phpt b/tests/replicaset/writeconcernerror-001.phpt index c839db2bb..892224c34 100644 --- a/tests/replicaset/writeconcernerror-001.phpt +++ b/tests/replicaset/writeconcernerror-001.phpt @@ -15,7 +15,7 @@ $bulk->insert(array("my" => "value")); $w = new MongoDB\Driver\WriteConcern(30, 100); try { - $retval = $manager->executeBulkWrite(NS, $bulk, $w); + $retval = $manager->executeBulkWrite(NS, $bulk, ['writeConcern' => $w]); } catch(MongoDB\Driver\Exception\BulkWriteException $e) { $server = $e->getWriteResult()->getServer(); $server->getPort(); diff --git a/tests/replicaset/writeconcernerror-002.phpt b/tests/replicaset/writeconcernerror-002.phpt index 39c038646..5fe8224a5 100644 --- a/tests/replicaset/writeconcernerror-002.phpt +++ b/tests/replicaset/writeconcernerror-002.phpt @@ -21,7 +21,7 @@ $bulk->update(array("foo" => "bar"), array('$set' => array("foo" => "baz")), arr $w = new MongoDB\Driver\WriteConcern(30); try { - $retval = $manager->executeBulkWrite(NS, $bulk, $w); + $retval = $manager->executeBulkWrite(NS, $bulk, ['writeConcern' => $w]); } catch(MongoDB\Driver\Exception\BulkWriteException $e) { printWriteResult($e->getWriteResult(), false); } diff --git a/tests/replicaset/writeresult-getserver-001.phpt b/tests/replicaset/writeresult-getserver-001.phpt index 93db60e4a..345190536 100644 --- a/tests/replicaset/writeresult-getserver-001.phpt +++ b/tests/replicaset/writeresult-getserver-001.phpt @@ -30,7 +30,7 @@ var_dump($server == $server2); $rp = new MongoDB\Driver\ReadPreference(MongoDB\Driver\ReadPreference::SECONDARY); /* Fetch a secondary */ -$server3 = $manager->executeQuery(NS, new MongoDB\Driver\Query(array()), $rp)->getServer(); +$server3 = $manager->executeQuery(NS, new MongoDB\Driver\Query([]), ['readPreference' => $rp])->getServer(); var_dump($server == $server3); var_dump($server->getPort(), $server3->getPort()); diff --git a/tests/replicaset/writeresult-getserver-002.phpt b/tests/replicaset/writeresult-getserver-002.phpt index 562de0a97..2a4d5ddd2 100644 --- a/tests/replicaset/writeresult-getserver-002.phpt +++ b/tests/replicaset/writeresult-getserver-002.phpt @@ -33,7 +33,7 @@ var_dump($server == $server2); $rp = new MongoDB\Driver\ReadPreference(MongoDB\Driver\ReadPreference::SECONDARY); /* Fetch a secondary */ -$server3 = $manager->executeQuery(NS, new MongoDB\Driver\Query(array()), $rp)->getServer(); +$server3 = $manager->executeQuery(NS, new MongoDB\Driver\Query([]), ['readPreference' => $rp])->getServer(); var_dump($server == $server3); var_dump($server->getPort(), $server3->getPort()); diff --git a/tests/server/server-executeBulkWrite-002.phpt b/tests/server/server-executeBulkWrite-002.phpt index 02ea0770e..9f65bd810 100644 --- a/tests/server/server-executeBulkWrite-002.phpt +++ b/tests/server/server-executeBulkWrite-002.phpt @@ -17,7 +17,7 @@ foreach ($writeConcerns as $writeConcern) { $bulk = new MongoDB\Driver\BulkWrite(); $bulk->insert(array('wc' => $writeConcern)); - $result = $primary->executeBulkWrite(NS, $bulk, new MongoDB\Driver\WriteConcern($writeConcern)); + $result = $primary->executeBulkWrite(NS, $bulk, ['writeConcern' => new MongoDB\Driver\WriteConcern($writeConcern)]); var_dump($result->isAcknowledged()); var_dump($result->getInsertedCount()); } diff --git a/tests/server/server-executeBulkWrite-003.phpt b/tests/server/server-executeBulkWrite-003.phpt index a31074f85..6ae75d0f6 100644 --- a/tests/server/server-executeBulkWrite-003.phpt +++ b/tests/server/server-executeBulkWrite-003.phpt @@ -18,7 +18,7 @@ foreach ($writeConcerns as $wc) { $bulk = new MongoDB\Driver\BulkWrite(); $bulk->insert(array('wc' => $wc)); - $result = $server->executeBulkWrite(NS, $bulk, new MongoDB\Driver\WriteConcern($wc)); + $result = $server->executeBulkWrite(NS, $bulk, ['writeConcern' => new MongoDB\Driver\WriteConcern($wc)]); var_dump($result->isAcknowledged()); var_dump($result->getInsertedCount()); } diff --git a/tests/server/server-executeBulkWrite-004.phpt b/tests/server/server-executeBulkWrite-004.phpt index d4398bdc1..bdd8b9979 100644 --- a/tests/server/server-executeBulkWrite-004.phpt +++ b/tests/server/server-executeBulkWrite-004.phpt @@ -21,7 +21,7 @@ foreach ($writeConcerns as $wc) { $bulk->insert(array('wc' => $wc)); echo throws(function() use ($server, $bulk, $wc) { - $server->executeBulkWrite(NS, $bulk, new MongoDB\Driver\WriteConcern($wc)); + $server->executeBulkWrite(NS, $bulk, ['writeConcern' => new MongoDB\Driver\WriteConcern($wc)]); }, "MongoDB\Driver\Exception\RuntimeException"), "\n"; } diff --git a/tests/server/server-executeBulkWrite-005.phpt b/tests/server/server-executeBulkWrite-005.phpt index 3a954dbf4..13035102b 100644 --- a/tests/server/server-executeBulkWrite-005.phpt +++ b/tests/server/server-executeBulkWrite-005.phpt @@ -23,7 +23,7 @@ foreach ($writeConcerns as $wc) { $bulk = new MongoDB\Driver\BulkWrite(); $bulk->insert(array('wc' => $wc)); - $result = $server->executeBulkWrite('local.' . COLLECTION_NAME, $bulk, new MongoDB\Driver\WriteConcern($wc)); + $result = $server->executeBulkWrite('local.' . COLLECTION_NAME, $bulk, ['writeConcern' => new MongoDB\Driver\WriteConcern($wc)]); var_dump($result->isAcknowledged()); var_dump($result->getInsertedCount()); } diff --git a/tests/server/server-executeBulkWrite-010.phpt b/tests/server/server-executeBulkWrite-010.phpt new file mode 100644 index 000000000..16af463c4 --- /dev/null +++ b/tests/server/server-executeBulkWrite-010.phpt @@ -0,0 +1,24 @@ +--TEST-- +MongoDB\Driver\Server::executeBulkWrite() explicit WriteConcern argument is deprecated +--SKIPIF-- + + + +--FILE-- +selectServer(); + +$bulk = new MongoDB\Driver\BulkWrite(); +$bulk->insert(['_id' => 1]); +$server->executeBulkWrite(NS, $bulk, new MongoDB\Driver\WriteConcern(0)); + +?> +===DONE=== + +--EXPECTF-- +Deprecated: MongoDB\Driver\Server::executeBulkWrite(): Passing the "writeConcern" option directly is deprecated and will be removed in ext-mongodb 2.0%s +===DONE=== diff --git a/tests/server/server-executeCommand-002.phpt b/tests/server/server-executeCommand-002.phpt index 065c3a88d..edfdf647b 100644 --- a/tests/server/server-executeCommand-002.phpt +++ b/tests/server/server-executeCommand-002.phpt @@ -25,7 +25,7 @@ $command = new MongoDB\Driver\Command([ 'pipeline' => [ [ '$match' => [ 'x' => 1 ] ] ], 'cursor' => (object) [], ]); -$secondary->executeCommand(DATABASE_NAME, $command, $rp); +$secondary->executeCommand(DATABASE_NAME, $command, ['readPreference' => $rp]); $query = new MongoDB\Driver\Query( array( @@ -37,7 +37,7 @@ $query = new MongoDB\Driver\Query( 'limit' => 1, ) ); -$cursor = $secondary->executeQuery(DATABASE_NAME . '.system.profile', $query, $rp); +$cursor = $secondary->executeQuery(DATABASE_NAME . '.system.profile', $query, ['readPreference' => $rp]); $profileEntry = current($cursor->toArray()); var_dump($profileEntry->command); diff --git a/tests/server/server-executeCommand-003.phpt b/tests/server/server-executeCommand-003.phpt index 36b0dde74..047b18e0c 100644 --- a/tests/server/server-executeCommand-003.phpt +++ b/tests/server/server-executeCommand-003.phpt @@ -17,7 +17,7 @@ $secondary = $manager->selectServer($secondaryRp); * no effect when directly querying a server, since the secondaryOk flag is always * set for hinted commands. */ $primaryRp = new MongoDB\Driver\ReadPreference(MongoDB\Driver\ReadPreference::PRIMARY); -$cursor = $secondary->executeCommand(DATABASE_NAME, new MongoDB\Driver\Command(array('ping' => 1)), $primaryRp); +$cursor = $secondary->executeCommand(DATABASE_NAME, new MongoDB\Driver\Command(array('ping' => 1)), ['readPreference' => $primaryRp]); var_dump($cursor->toArray()); diff --git a/tests/server/server-executeCommand-005.phpt b/tests/server/server-executeCommand-005.phpt index 20cca0c58..6f24e31da 100644 --- a/tests/server/server-executeCommand-005.phpt +++ b/tests/server/server-executeCommand-005.phpt @@ -35,10 +35,14 @@ echo "is_secondary: ", $cursor->getServer()->isSecondary() ? 'true' : 'false', " --EXPECTF-- Testing primary: + +Deprecated: MongoDB\Driver\Server::executeCommand(): Passing the "readPreference" option directly is deprecated and will be removed in ext-mongodb 2.0%s is_primary: true is_secondary: false Testing secondary: + +Deprecated: MongoDB\Driver\Server::executeCommand(): Passing the "readPreference" option directly is deprecated and will be removed in ext-mongodb 2.0%s is_primary: false is_secondary: true diff --git a/tests/server/server-executeQuery-006.phpt b/tests/server/server-executeQuery-006.phpt index 90a714b26..be1d75cf8 100644 --- a/tests/server/server-executeQuery-006.phpt +++ b/tests/server/server-executeQuery-006.phpt @@ -24,7 +24,7 @@ if (empty($result->ok)) { exit("Could not set profile level\n"); } -$secondary->executeQuery(NS, new MongoDB\Driver\Query(array("x" => 1)), $rp); +$secondary->executeQuery(NS, new MongoDB\Driver\Query(['x' => 1]), ['readPreference' => $rp]); $query = new MongoDB\Driver\Query( array( @@ -36,7 +36,7 @@ $query = new MongoDB\Driver\Query( 'limit' => 1, ) ); -$cursor = $secondary->executeQuery(DATABASE_NAME . '.system.profile', $query, $rp); +$cursor = $secondary->executeQuery(DATABASE_NAME . '.system.profile', $query, ['readPreference' => $rp]); $profileEntry = current($cursor->toArray()); if (! isset( $profileEntry->command )) { diff --git a/tests/server/server-executeQuery-008.phpt b/tests/server/server-executeQuery-008.phpt index 9d2f915ac..b34f83422 100644 --- a/tests/server/server-executeQuery-008.phpt +++ b/tests/server/server-executeQuery-008.phpt @@ -21,7 +21,7 @@ $dataBearingNodes = count(array_filter($manager->getServers(), function (MongoDB $bulk = new \MongoDB\Driver\BulkWrite; $bulk->insert(['_id' => 1, 'x' => 1]); -$primary->executeBulkWrite(NS, $bulk, new MongoDB\Driver\WriteConcern($dataBearingNodes)); +$primary->executeBulkWrite(NS, $bulk, ['writeConcern' => new MongoDB\Driver\WriteConcern($dataBearingNodes)]); $secondaryRp = new MongoDB\Driver\ReadPreference(MongoDB\Driver\ReadPreference::SECONDARY); $secondary = $manager->selectServer($secondaryRp); @@ -29,7 +29,7 @@ $secondary = $manager->selectServer($secondaryRp); /* Note: this is testing that the read preference (even a conflicting one) has * no effect when directly querying a server, since the secondaryOk flag is always * set for hinted queries. */ -$cursor = $secondary->executeQuery(NS, new MongoDB\Driver\Query(['x' => 1]), $primaryRp); +$cursor = $secondary->executeQuery(NS, new MongoDB\Driver\Query(['x' => 1]), ['readPreference' => $primaryRp]); var_dump($cursor->toArray()); diff --git a/tests/server/server-executeQuery-010.phpt b/tests/server/server-executeQuery-010.phpt index 1a85b4bf4..7eb3d74f4 100644 --- a/tests/server/server-executeQuery-010.phpt +++ b/tests/server/server-executeQuery-010.phpt @@ -24,14 +24,14 @@ $secondary = $manager->selectServer($secondaryRp); echo "Testing primary:\n"; $query = new MongoDB\Driver\Query(['x' => 3], ['projection' => ['y' => 1]]); -$cursor = $manager->executeQuery(NS, $query, $primaryRp); +$cursor = $primary->executeQuery(NS, $query, $primaryRp); echo "is_primary: ", $cursor->getServer()->isPrimary() ? 'true' : 'false', "\n"; echo "is_secondary: ", $cursor->getServer()->isSecondary() ? 'true' : 'false', "\n\n"; echo "Testing secondary:\n"; $query = new MongoDB\Driver\Query(['x' => 3], ['projection' => ['y' => 1]]); -$cursor = $manager->executeQuery(NS, $query, $secondaryRp); +$cursor = $secondary->executeQuery(NS, $query, $secondaryRp); echo "is_primary: ", $cursor->getServer()->isPrimary() ? 'true' : 'false', "\n"; echo "is_secondary: ", $cursor->getServer()->isSecondary() ? 'true' : 'false', "\n\n"; @@ -40,10 +40,14 @@ echo "is_secondary: ", $cursor->getServer()->isSecondary() ? 'true' : 'false', " --EXPECTF-- Testing primary: + +Deprecated: MongoDB\Driver\Server::executeQuery(): Passing the "readPreference" option directly is deprecated and will be removed in ext-mongodb 2.0%s is_primary: true is_secondary: false Testing secondary: + +Deprecated: MongoDB\Driver\Server::executeQuery(): Passing the "readPreference" option directly is deprecated and will be removed in ext-mongodb 2.0%s is_primary: false is_secondary: true diff --git a/tests/standalone/bug0545.phpt b/tests/standalone/bug0545.phpt index fef846365..ab292c437 100644 --- a/tests/standalone/bug0545.phpt +++ b/tests/standalone/bug0545.phpt @@ -57,7 +57,7 @@ $page1->content = 'Lorem ipsum'; $book->pages[] = $page1; $bulk = new MongoDB\Driver\BulkWrite; $bulk->insert($book); -$result = $manager->executeBulkWrite(NS, $bulk, $wc); +$result = $manager->executeBulkWrite(NS, $bulk, ['writeConcern' => $wc]); printf("Inserted %d document(s)\n", $result->getInsertedCount()); // Read @@ -72,7 +72,7 @@ $page2->content = 'Dolor sit amet'; $bookAfterInsert->pages[] = $page2; $bulk = new MongoDB\Driver\BulkWrite; $bulk->update(['title' => $bookAfterInsert->title], $bookAfterInsert); -$result = $manager->executeBulkWrite(NS, $bulk, $wc); +$result = $manager->executeBulkWrite(NS, $bulk, ['writeConcern' => $wc]); printf("Modified %d document(s)\n", $result->getModifiedCount()); // Read (again) diff --git a/tests/standalone/manager-as-singleton.phpt b/tests/standalone/manager-as-singleton.phpt index 4cdd333de..8978710e3 100644 --- a/tests/standalone/manager-as-singleton.phpt +++ b/tests/standalone/manager-as-singleton.phpt @@ -30,7 +30,7 @@ class Database { } public function query($scheme, $query) { - return $this->Database->executeQuery($scheme, $query, new ReadPreference(ReadPreference::PRIMARY)); + return $this->Database->executeQuery($scheme, $query, ['readPreference' => new ReadPreference(ReadPreference::PRIMARY)]); } } diff --git a/tests/standalone/write-error-001.phpt b/tests/standalone/write-error-001.phpt index 530af2fb9..12f3359f2 100644 --- a/tests/standalone/write-error-001.phpt +++ b/tests/standalone/write-error-001.phpt @@ -20,7 +20,7 @@ $w = 2; $wtimeout = 1000; $writeConcern = new \MongoDB\Driver\WriteConcern($w, $wtimeout); echo throws(function() use($bulk, $writeConcern, $manager) { - $result = $manager->executeBulkWrite(NS, $bulk, $writeConcern); + $result = $manager->executeBulkWrite(NS, $bulk, ['writeConcern' => $writeConcern]); }, "MongoDB\Driver\Exception\BulkWriteException"), "\n"; ?> diff --git a/tests/standalone/writeresult-isacknowledged-003.phpt b/tests/standalone/writeresult-isacknowledged-003.phpt index e30e53312..5d679910e 100644 --- a/tests/standalone/writeresult-isacknowledged-003.phpt +++ b/tests/standalone/writeresult-isacknowledged-003.phpt @@ -12,7 +12,7 @@ $manager = create_test_manager(); $bulk = new \MongoDB\Driver\BulkWrite; $bulk->insert(array('x' => 2)); -$result = $manager->executeBulkWrite(NS, $bulk, new MongoDB\Driver\WriteConcern(0)); +$result = $manager->executeBulkWrite(NS, $bulk, ['writeConcern' => new MongoDB\Driver\WriteConcern(0)]); printf("WriteResult::isAcknowledged(): %s\n", $result->isAcknowledged() ? 'true' : 'false'); var_dump($result); diff --git a/tests/writeConcernError/writeconcernerror-debug-001.phpt b/tests/writeConcernError/writeconcernerror-debug-001.phpt index a164aa8d8..c9761436f 100644 --- a/tests/writeConcernError/writeconcernerror-debug-001.phpt +++ b/tests/writeConcernError/writeconcernerror-debug-001.phpt @@ -15,7 +15,7 @@ $bulk->insert(['x' => 1]); try { /* We assume that the replica set does not have 12 nodes */ - $manager->executeBulkWrite(NS, $bulk, new MongoDB\Driver\WriteConcern(12)); + $manager->executeBulkWrite(NS, $bulk, ['writeConcern' => new MongoDB\Driver\WriteConcern(12)]); } catch(MongoDB\Driver\Exception\BulkWriteException $e) { var_dump($e->getWriteResult()->getWriteConcernError()); } diff --git a/tests/writeConcernError/writeconcernerror-getcode-001.phpt b/tests/writeConcernError/writeconcernerror-getcode-001.phpt index e34dc95a9..fb4c682e9 100644 --- a/tests/writeConcernError/writeconcernerror-getcode-001.phpt +++ b/tests/writeConcernError/writeconcernerror-getcode-001.phpt @@ -15,7 +15,7 @@ $bulk->insert(['x' => 1]); try { /* We assume that the replica set does not have 12 nodes */ - $manager->executeBulkWrite(NS, $bulk, new MongoDB\Driver\WriteConcern(12)); + $manager->executeBulkWrite(NS, $bulk, ['writeConcern' => new MongoDB\Driver\WriteConcern(12)]); } catch(MongoDB\Driver\Exception\BulkWriteException $e) { var_dump($e->getWriteResult()->getWriteConcernError()->getCode()); } diff --git a/tests/writeConcernError/writeconcernerror-getmessage-001.phpt b/tests/writeConcernError/writeconcernerror-getmessage-001.phpt index 4f578ac36..27d4e16c1 100644 --- a/tests/writeConcernError/writeconcernerror-getmessage-001.phpt +++ b/tests/writeConcernError/writeconcernerror-getmessage-001.phpt @@ -15,7 +15,7 @@ $bulk->insert(['x' => 1]); try { /* We assume that the replica set does not have 12 nodes */ - $manager->executeBulkWrite(NS, $bulk, new MongoDB\Driver\WriteConcern(12)); + $manager->executeBulkWrite(NS, $bulk, ['writeConcern' => new MongoDB\Driver\WriteConcern(12)]); } catch(MongoDB\Driver\Exception\BulkWriteException $e) { var_dump($e->getWriteResult()->getWriteConcernError()->getMessage()); } diff --git a/tests/writeResult/writeresult-debug-002.phpt b/tests/writeResult/writeresult-debug-002.phpt index b2e4fce86..eea6ea523 100644 --- a/tests/writeResult/writeresult-debug-002.phpt +++ b/tests/writeResult/writeresult-debug-002.phpt @@ -22,7 +22,7 @@ $bulk->insert(['_id' => 3]); try { /* We assume that the replica set does not have 30 nodes */ - $result = $manager->executeBulkWrite(NS, $bulk, new MongoDB\Driver\WriteConcern(30)); + $result = $manager->executeBulkWrite(NS, $bulk, ['writeConcern' => new MongoDB\Driver\WriteConcern(30)]); } catch (MongoDB\Driver\Exception\BulkWriteException $e) { var_dump($e->getWriteResult()); } diff --git a/tests/writeResult/writeresult-getdeletedcount-002.phpt b/tests/writeResult/writeresult-getdeletedcount-002.phpt index a3008f22c..394f8c7dc 100644 --- a/tests/writeResult/writeresult-getdeletedcount-002.phpt +++ b/tests/writeResult/writeresult-getdeletedcount-002.phpt @@ -17,7 +17,7 @@ $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, new MongoDB\Driver\WriteConcern(0)); +$result = $manager->executeBulkWrite(NS, $bulk, ['writeConcern' => new MongoDB\Driver\WriteConcern(0)]); var_dump($result->getDeletedCount()); diff --git a/tests/writeResult/writeresult-getinsertedcount-002.phpt b/tests/writeResult/writeresult-getinsertedcount-002.phpt index 4f671b36d..480498da4 100644 --- a/tests/writeResult/writeresult-getinsertedcount-002.phpt +++ b/tests/writeResult/writeresult-getinsertedcount-002.phpt @@ -17,7 +17,7 @@ $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, new MongoDB\Driver\WriteConcern(0)); +$result = $manager->executeBulkWrite(NS, $bulk, ['writeConcern' => new MongoDB\Driver\WriteConcern(0)]); var_dump($result->getInsertedCount()); diff --git a/tests/writeResult/writeresult-getmatchedcount-002.phpt b/tests/writeResult/writeresult-getmatchedcount-002.phpt index 75b93c704..153cca2e3 100644 --- a/tests/writeResult/writeresult-getmatchedcount-002.phpt +++ b/tests/writeResult/writeresult-getmatchedcount-002.phpt @@ -17,7 +17,7 @@ $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, new MongoDB\Driver\WriteConcern(0)); +$result = $manager->executeBulkWrite(NS, $bulk, ['writeConcern' => new MongoDB\Driver\WriteConcern(0)]); var_dump($result->getMatchedCount()); diff --git a/tests/writeResult/writeresult-getmodifiedcount-002.phpt b/tests/writeResult/writeresult-getmodifiedcount-002.phpt index a27e99c19..43f7d2e4e 100644 --- a/tests/writeResult/writeresult-getmodifiedcount-002.phpt +++ b/tests/writeResult/writeresult-getmodifiedcount-002.phpt @@ -17,7 +17,7 @@ $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, new MongoDB\Driver\WriteConcern(0)); +$result = $manager->executeBulkWrite(NS, $bulk, ['writeConcern' => new MongoDB\Driver\WriteConcern(0)]); var_dump($result->getModifiedCount()); diff --git a/tests/writeResult/writeresult-getupsertedcount-002.phpt b/tests/writeResult/writeresult-getupsertedcount-002.phpt index af42f26b6..a2b986355 100644 --- a/tests/writeResult/writeresult-getupsertedcount-002.phpt +++ b/tests/writeResult/writeresult-getupsertedcount-002.phpt @@ -17,7 +17,7 @@ $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, new MongoDB\Driver\WriteConcern(0)); +$result = $manager->executeBulkWrite(NS, $bulk, ['writeConcern' => new MongoDB\Driver\WriteConcern(0)]); var_dump($result->getUpsertedCount()); diff --git a/tests/writeResult/writeresult-getwriteconcernerror-001.phpt b/tests/writeResult/writeresult-getwriteconcernerror-001.phpt index 73fd56e72..0952a93f9 100644 --- a/tests/writeResult/writeresult-getwriteconcernerror-001.phpt +++ b/tests/writeResult/writeresult-getwriteconcernerror-001.phpt @@ -15,7 +15,7 @@ $bulk->insert(['x' => 1]); try { /* We assume that the replica set does not have 12 nodes */ - $result = $manager->executeBulkWrite(NS, $bulk, new MongoDB\Driver\WriteConcern(12)); + $result = $manager->executeBulkWrite(NS, $bulk, ['writeConcern' => new MongoDB\Driver\WriteConcern(12)]); } catch (MongoDB\Driver\Exception\BulkWriteException $e) { var_dump($e->getWriteResult()->getWriteConcernError()); } diff --git a/tests/writeResult/writeresult-isacknowledged-001.phpt b/tests/writeResult/writeresult-isacknowledged-001.phpt index 5f0d1a41c..4405a449b 100644 --- a/tests/writeResult/writeresult-isacknowledged-001.phpt +++ b/tests/writeResult/writeresult-isacknowledged-001.phpt @@ -19,7 +19,7 @@ foreach ($wcs as $wc) { $bulk = new MongoDB\Driver\BulkWrite; $bulk->insert(['x' => 1]); - $result = $manager->executeBulkWrite(NS, $bulk, $wc); + $result = $manager->executeBulkWrite(NS, $bulk, ['writeConcern' => $wc]); var_dump($result->isAcknowledged()); } From 45c8aeb0dfa06963deffbc7ee9bbc132cfa47c9e Mon Sep 17 00:00:00 2001 From: Jeremy Mikola Date: Thu, 30 Jan 2025 10:27:29 -0500 Subject: [PATCH 6/7] PHPC-2501: Conditionally define MONGOC_CYRUS_PLUGIN_PATH_PREFIX on Windows (#1777) This was missed in 6a2e15ae1fea545b750dff2977924f7e3eaf4af7 when bumping to libmongoc 1.26.2. Define the constant as null to satisfy compilation. It will not actually be used for path prefix checking. --- config.w32 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/config.w32 b/config.w32 index 91199a87b..0c9923540 100644 --- a/config.w32 +++ b/config.w32 @@ -239,6 +239,10 @@ if (PHP_MONGODB != "no") { CHECK_HEADER_ADD_INCLUDE("sasl/sasl.h", "CFLAGS_MONGODB")) { mongoc_opts.MONGOC_ENABLE_SASL = 1; mongoc_opts.MONGOC_ENABLE_SASL_CYRUS = 1; + + // Referenced by _mongoc_cyrus_verifyfile_cb in mongoc-cyrus.c on Windows + ADD_FLAG("CFLAGS_MONGODB", "/D MONGOC_CYRUS_PLUGIN_PATH_PREFIX=NULL"); + if (CHECK_FUNC_IN_HEADER("sasl/sasl.h", "sasl_client_done")) { mongoc_opts.MONGOC_HAVE_SASL_CLIENT_DONE = 1; } From 65bbd1b34caf119bf8a1e20e0b2ad1edfe29a670 Mon Sep 17 00:00:00 2001 From: Jeremy Mikola Date: Fri, 31 Jan 2025 09:46:12 -0500 Subject: [PATCH 7/7] PHPC-2503: Conditionally allow more concise output for libbson 1.30 (#1779) mongodb/mongo-c-driver@f2c1bb7989177fa2ddba1a915e8423e46ee1defe reduced the whitespace for empty arrays and documents. The EXPECTF pattern is necessary for compatibility with earlier versions of libbson, but it can be removed once libbson 1.30+ is formally required. --- tests/bson/bson-encode-001.phpt | 6 +++--- tests/bson/bson-encode-004.phpt | 2 +- tests/bson/bson-encode-005.phpt | 2 +- tests/readPreference/readpreference-bsonserialize-001.phpt | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/bson/bson-encode-001.phpt b/tests/bson/bson-encode-001.phpt index 84149bed9..cfd8d8874 100644 --- a/tests/bson/bson-encode-001.phpt +++ b/tests/bson/bson-encode-001.phpt @@ -39,7 +39,7 @@ foreach($tests as $n => $test) { ?> ===DONE=== ---EXPECT-- +--EXPECTF-- Test#0 { "hello" : "world" } 0 : 16 00 00 00 02 68 65 6c 6c 6f 00 06 00 00 00 77 [.....hello.....w] 10 : 6f 72 6c 64 00 00 [orld..] @@ -98,7 +98,7 @@ Test#16 { "foo" : "test", "0" : "foo", "1" : "bar" } 0 : 29 00 00 00 02 66 6f 6f 00 05 00 00 00 74 65 73 [)....foo.....tes] 10 : 74 00 02 30 00 04 00 00 00 66 6f 6f 00 02 31 00 [t..0.....foo..1.] 20 : 04 00 00 00 62 61 72 00 00 [....bar..] -Test#17 { "int" : { "$numberInt" : "3" }, "boolean" : true, "array" : [ "foo", "bar" ], "object" : { }, "string" : "test", "3" : "test" } +Test#17 { "int" : { "$numberInt" : "3" }, "boolean" : true, "array" : [ "foo", "bar" ], "object" : { %w}, "string" : "test", "3" : "test" } 0 : 64 00 00 00 10 69 6e 74 00 03 00 00 00 08 62 6f [d....int......bo] 10 : 6f 6c 65 61 6e 00 01 04 61 72 72 61 79 00 1b 00 [olean...array...] 20 : 00 00 02 30 00 04 00 00 00 66 6f 6f 00 02 31 00 [...0.....foo..1.] @@ -123,7 +123,7 @@ Test#21 { "0" : { "foo" : "test", "0" : "foo", "1" : "bar" } } 10 : 05 00 00 00 74 65 73 74 00 02 30 00 04 00 00 00 [....test..0.....] 20 : 66 6f 6f 00 02 31 00 04 00 00 00 62 61 72 00 00 [foo..1.....bar..] 30 : 00 [.] -Test#22 { "0" : { "int" : { "$numberInt" : "3" }, "boolean" : true, "array" : [ "foo", "bar" ], "object" : { }, "string" : "test", "3" : "test" } } +Test#22 { "0" : { "int" : { "$numberInt" : "3" }, "boolean" : true, "array" : [ "foo", "bar" ], "object" : { %w}, "string" : "test", "3" : "test" } } 0 : 6c 00 00 00 03 30 00 64 00 00 00 10 69 6e 74 00 [l....0.d....int.] 10 : 03 00 00 00 08 62 6f 6f 6c 65 61 6e 00 01 04 61 [.....boolean...a] 20 : 72 72 61 79 00 1b 00 00 00 02 30 00 04 00 00 00 [rray......0.....] diff --git a/tests/bson/bson-encode-004.phpt b/tests/bson/bson-encode-004.phpt index 1d6f2751d..8ec0446f2 100644 --- a/tests/bson/bson-encode-004.phpt +++ b/tests/bson/bson-encode-004.phpt @@ -71,7 +71,7 @@ object(Person)#%d (5) { ["secret":protected]=> string(24) "Hannes confidential info" } -Test { "0" : { "__pclass" : { "$binary" : { "base64" : "UGVyc29u", "subType" : "80" } }, "name" : "Hannes", "age" : { "$numberInt" : "42" }, "addresses" : [ { "__pclass" : { "$binary" : { "base64" : "QWRkcmVzcw==", "subType" : "80" } }, "zip" : { "$numberInt" : "94086" }, "country" : "USA" }, { "__pclass" : { "$binary" : { "base64" : "QWRkcmVzcw==", "subType" : "80" } }, "zip" : { "$numberInt" : "200" }, "country" : "Iceland" } ], "friends" : [ { "__pclass" : { "$binary" : { "base64" : "UGVyc29u", "subType" : "80" } }, "name" : "Jeremy", "age" : { "$numberInt" : "21" }, "addresses" : [ ], "friends" : [ ] } ] } } +Test { "0" : { "__pclass" : { "$binary" : { "base64" : "UGVyc29u", "subType" : "80" } }, "name" : "Hannes", "age" : { "$numberInt" : "42" }, "addresses" : [ { "__pclass" : { "$binary" : { "base64" : "QWRkcmVzcw==", "subType" : "80" } }, "zip" : { "$numberInt" : "94086" }, "country" : "USA" }, { "__pclass" : { "$binary" : { "base64" : "QWRkcmVzcw==", "subType" : "80" } }, "zip" : { "$numberInt" : "200" }, "country" : "Iceland" } ], "friends" : [ { "__pclass" : { "$binary" : { "base64" : "UGVyc29u", "subType" : "80" } }, "name" : "Jeremy", "age" : { "$numberInt" : "21" }, "addresses" : [ %w], "friends" : [ %w] } ] } } 0 : 23 01 00 00 03 30 00 1b 01 00 00 05 5f 5f 70 63 [#....0......__pc] 10 : 6c 61 73 73 00 06 00 00 00 80 50 65 72 73 6f 6e [lass......Person] 20 : 02 6e 61 6d 65 00 07 00 00 00 48 61 6e 6e 65 73 [.name.....Hannes] diff --git a/tests/bson/bson-encode-005.phpt b/tests/bson/bson-encode-005.phpt index 27f6f41dd..a66937b95 100644 --- a/tests/bson/bson-encode-005.phpt +++ b/tests/bson/bson-encode-005.phpt @@ -19,7 +19,7 @@ var_dump($ret); ===DONE=== --EXPECTF-- -Test { "emptyarray" : [ ], "emptyclass" : { } } +Test { "emptyarray" : [ %w], "emptyclass" : { %w} } 0 : 27 00 00 00 04 65 6d 70 74 79 61 72 72 61 79 00 ['....emptyarray.] 10 : 05 00 00 00 00 03 65 6d 70 74 79 63 6c 61 73 73 [......emptyclass] 20 : 00 05 00 00 00 00 00 [.......] diff --git a/tests/readPreference/readpreference-bsonserialize-001.phpt b/tests/readPreference/readpreference-bsonserialize-001.phpt index 50980cab8..5bff10162 100644 --- a/tests/readPreference/readpreference-bsonserialize-001.phpt +++ b/tests/readPreference/readpreference-bsonserialize-001.phpt @@ -24,7 +24,7 @@ foreach ($tests as $test) { ?> ===DONE=== ---EXPECT-- +--EXPECTF-- { "mode" : "primary" } { "mode" : "primaryPreferred" } { "mode" : "secondary" } @@ -32,6 +32,6 @@ foreach ($tests as $test) { { "mode" : "nearest" } { "mode" : "primary" } { "mode" : "secondary", "tags" : [ { "dc" : "ny" } ] } -{ "mode" : "secondary", "tags" : [ { "dc" : "ny" }, { "dc" : "sf", "use" : "reporting" }, { } ] } +{ "mode" : "secondary", "tags" : [ { "dc" : "ny" }, { "dc" : "sf", "use" : "reporting" }, { %w} ] } { "mode" : "secondary", "maxStalenessSeconds" : { "$numberInt" : "1000" } } ===DONE===