Skip to content

Commit

Permalink
Merge v1.x into v2.x (#1780)
Browse files Browse the repository at this point in the history
  • Loading branch information
mongodb-php-bot authored Jan 31, 2025
2 parents cd3593b + 37f7f9a commit fcd9b83
Show file tree
Hide file tree
Showing 53 changed files with 129 additions and 173 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 0 additions & 2 deletions config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,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)
Expand All @@ -312,7 +311,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
Expand Down
20 changes: 5 additions & 15 deletions config.w32
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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,
Expand All @@ -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",
Expand Down Expand Up @@ -253,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;
}
Expand Down
16 changes: 8 additions & 8 deletions sbom.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,34 +19,34 @@
"version": "1.12.0"
},
{
"bom-ref": "pkg:github/mongodb/[email protected].0",
"bom-ref": "pkg:github/mongodb/[email protected].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/[email protected].0",
"purl": "pkg:github/mongodb/[email protected].2",
"type": "library",
"version": "1.29.0"
"version": "1.29.2"
}
],
"dependencies": [
{
"ref": "pkg:github/mongodb/[email protected]"
},
{
"ref": "pkg:github/mongodb/[email protected].0"
"ref": "pkg:github/mongodb/[email protected].2"
}
],
"metadata": {
"timestamp": "2024-11-12T18:00:38.546484+00:00",
"timestamp": "2025-01-14T14:24:24.250261+00:00",
"tools": [
{
"externalReferences": [
Expand Down Expand Up @@ -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",
Expand Down
23 changes: 0 additions & 23 deletions scripts/autotools/libbson/CheckAtomics.m4

This file was deleted.

67 changes: 0 additions & 67 deletions scripts/autotools/libbson/FindDependencies.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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 <stdlib.h>
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 <unistd.h>
#include <sys/syscall.h>
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 <unistd.h>
#include <sys/syscall.h>
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)])
Expand All @@ -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.
Expand All @@ -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.h>
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
9 changes: 0 additions & 9 deletions scripts/autotools/libmongoc/WeakSymbols.m4

This file was deleted.

2 changes: 1 addition & 1 deletion src/LIBMONGOC_VERSION_CURRENT
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.29.0
1.29.2
2 changes: 2 additions & 0 deletions src/phongo_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
6 changes: 3 additions & 3 deletions tests/bson/bson-encode-001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ foreach($tests as $n => $test) {
?>
===DONE===
<?php exit(0); ?>
--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..]
Expand Down Expand Up @@ -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.]
Expand All @@ -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.....]
Expand Down
2 changes: 1 addition & 1 deletion tests/bson/bson-encode-004.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion tests/bson/bson-encode-005.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var_dump($ret);
===DONE===
<?php exit(0); ?>
--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 [.......]
Expand Down
2 changes: 1 addition & 1 deletion tests/bulk/write-0002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
23 changes: 23 additions & 0 deletions tests/manager/manager-executeBulkWrite-015.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
--TEST--
MongoDB\Driver\Manager::executeBulkWrite() explicit WriteConcern argument is deprecated
--SKIPIF--
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
<?php skip_if_not_live(); ?>
<?php skip_if_not_clean(); ?>
--FILE--
<?php

require_once __DIR__ . "/../utils/basic.inc";

$manager = create_test_manager();

$bulk = new MongoDB\Driver\BulkWrite();
$bulk->insert(['_id' => 1]);
$manager->executeBulkWrite(NS, $bulk, new MongoDB\Driver\WriteConcern(0));

?>
===DONE===
<?php exit(0); ?>
--EXPECTF--
Deprecated: MongoDB\Driver\Manager::executeBulkWrite(): Passing the "writeConcern" option directly is deprecated and will be removed in ext-mongodb 2.0%s
===DONE===
2 changes: 1 addition & 1 deletion tests/manager/manager-executeBulkWrite_error-003.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down
4 changes: 4 additions & 0 deletions tests/manager/manager-executeCommand-003.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,14 @@ echo "is_secondary: ", $cursor->getServer()->isSecondary() ? 'true' : 'false', "
<?php exit(0); ?>
--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

Expand Down
4 changes: 4 additions & 0 deletions tests/manager/manager-executeQuery-004.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,14 @@ echo "is_secondary: ", $cursor->getServer()->isSecondary() ? 'true' : 'false', "
<?php exit(0); ?>
--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

Expand Down
2 changes: 1 addition & 1 deletion tests/readPreference/bug0146-001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
Loading

0 comments on commit fcd9b83

Please sign in to comment.