Skip to content

Merge v1.x into v2.x #1796

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .evergreen/config/generated/build/build-libmongoc.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .evergreen/config/templates/build/build-libmongoc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
- func: "compile driver"
vars:
PHP_VERSION: "%phpVersion%"
LIBMONGOC_VERSION: "1.30.0"
LIBMONGOC_VERSION: "1.30.1"
- func: "upload build"

- name: "build-php-%phpVersion%-libmongoc-next-stable"
Expand Down
8 changes: 4 additions & 4 deletions config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -277,26 +277,26 @@ if test "$PHP_MONGODB" != "no"; then
PHP_MONGODB_MONGOCRYPT_VERSION_STRING="None"

if test "$PHP_MONGODB_SYSTEM_LIBS" != "no"; then
PKG_CHECK_MODULES([PHP_MONGODB_BSON], [libbson-1.0 >= 1.30.0], [
PKG_CHECK_MODULES([PHP_MONGODB_BSON], [libbson-1.0 >= 1.30.1], [
PHP_MONGODB_BSON_VERSION=`$PKG_CONFIG libbson-1.0 --modversion`
PHP_MONGODB_BSON_VERSION_STRING="System ($PHP_MONGODB_BSON_VERSION)"

PHP_MONGODB_CFLAGS="$PHP_MONGODB_CFLAGS $PHP_MONGODB_BSON_CFLAGS"
PHP_EVAL_LIBLINE($PHP_MONGODB_BSON_LIBS, MONGODB_SHARED_LIBADD)
AC_DEFINE(HAVE_SYSTEM_LIBBSON, 1, [Use system libbson])
],[
AC_MSG_ERROR([Could not find system library for libbson >= 1.30.0])
AC_MSG_ERROR([Could not find system library for libbson >= 1.30.1])
])

PKG_CHECK_MODULES([PHP_MONGODB_MONGOC], [libmongoc-1.0 >= 1.30.0], [
PKG_CHECK_MODULES([PHP_MONGODB_MONGOC], [libmongoc-1.0 >= 1.30.1], [
PHP_MONGODB_BSON_VERSION=`$PKG_CONFIG libbson-1.0 --modversion`
PHP_MONGODB_BSON_VERSION_STRING="System ($PHP_MONGODB_BSON_VERSION)"

PHP_MONGODB_CFLAGS="$PHP_MONGODB_CFLAGS $PHP_MONGODB_MONGOC_CFLAGS"
PHP_EVAL_LIBLINE($PHP_MONGODB_MONGOC_LIBS, MONGODB_SHARED_LIBADD)
AC_DEFINE(HAVE_SYSTEM_LIBMONGOC, 1, [Use system libmongoc])
],[
AC_MSG_ERROR(Could not find system library for libmongoc >= 1.30.0)
AC_MSG_ERROR(Could not find system library for libmongoc >= 1.30.1)
])

if test "$PHP_MONGODB_CLIENT_SIDE_ENCRYPTION" != "no"; then
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].1",
"externalReferences": [
{
"type": "distribution",
"url": "https://github.com/mongodb/mongo-c-driver/archive/refs/tags/1.30.0.tar.gz"
"url": "https://github.com/mongodb/mongo-c-driver/archive/refs/tags/1.30.1.tar.gz"
},
{
"type": "website",
"url": "https://github.com/mongodb/mongo-c-driver/tree/1.30.0"
"url": "https://github.com/mongodb/mongo-c-driver/tree/1.30.1"
}
],
"group": "mongodb",
"name": "mongo-c-driver",
"purl": "pkg:github/mongodb/[email protected].0",
"purl": "pkg:github/mongodb/[email protected].1",
"type": "library",
"version": "1.30.0"
"version": "1.30.1"
}
],
"dependencies": [
{
"ref": "pkg:github/mongodb/[email protected]"
},
{
"ref": "pkg:github/mongodb/[email protected].0"
"ref": "pkg:github/mongodb/[email protected].1"
}
],
"metadata": {
"timestamp": "2025-02-07T15:48:29.888317+00:00",
"timestamp": "2025-02-21T15:21:36.741928+00:00",
"tools": [
{
"externalReferences": [
Expand Down Expand Up @@ -90,7 +90,7 @@
]
},
"serialNumber": "urn:uuid:acb30d08-ee47-4ff0-b301-d66ef1f54082",
"version": 9,
"version": 10,
"$schema": "http://cyclonedx.org/schema/bom-1.5.schema.json",
"bomFormat": "CycloneDX",
"specVersion": "1.5",
Expand Down
2 changes: 1 addition & 1 deletion src/LIBMONGOC_VERSION_CURRENT
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.30.0
1.30.1
1 change: 1 addition & 0 deletions src/MongoDB/BulkWrite.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ static bool php_phongo_bulkwrite_update_apply_options(bson_t* boptions, zval* zo
PHONGO_BULKWRITE_APPEND_BOOL("upsert", upsert);
PHONGO_BULKWRITE_OPT_ARRAY("arrayFilters");
PHONGO_BULKWRITE_OPT_DOCUMENT("collation");
PHONGO_BULKWRITE_OPT_DOCUMENT("sort");

if (!php_phongo_bulkwrite_opt_hint(boptions, zoptions)) {
return false;
Expand Down
81 changes: 81 additions & 0 deletions tests/bulk/bulkwrite-update-008.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
--TEST--
MongoDB\Driver\BulkWrite::update() with sort option
--SKIPIF--
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
<?php skip_if_not_live(); ?>
<?php skip_if_server_version('<', '8.0'); ?>
<?php skip_if_not_clean(); ?>
--FILE--
<?php
require_once __DIR__ . "/../utils/basic.inc";

class CommandLogger implements MongoDB\Driver\Monitoring\CommandSubscriber
{
public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void
{
if ($event->getCommandName() !== 'update') {
return;
}

printf("update included sort: %s\n", json_encode($event->getCommand()->updates[0]->sort));
}

public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void
{
}

public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void
{
}
}

$manager = create_test_manager();

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

MongoDB\Driver\Monitoring\addSubscriber(new CommandLogger);

$bulk = new MongoDB\Driver\BulkWrite;
$bulk->update(['_id' => ['$gt' => 1]], ['$set' => ['x' => 11]], ['sort' => ['_id' => 1]]);
$manager->executeBulkWrite(NS, $bulk);

$bulk = new MongoDB\Driver\BulkWrite;
$bulk->update(['_id' => ['$gt' => 1]], ['x' => 22], ['sort' => ['_id' => -1]]);
$manager->executeBulkWrite(NS, $bulk);

$cursor = $manager->executeQuery(NS, new MongoDB\Driver\Query([]));

var_dump($cursor->toArray());

?>
===DONE===
<?php exit(0); ?>
--EXPECTF--
update included sort: {"_id":1}
update included sort: {"_id":-1}
array(3) {
[0]=>
object(stdClass)#%d (%d) {
["_id"]=>
int(1)
}
[1]=>
object(stdClass)#%d (%d) {
["_id"]=>
int(2)
["x"]=>
int(11)
}
[2]=>
object(stdClass)#%d (%d) {
["_id"]=>
int(3)
["x"]=>
int(22)
}
}
===DONE===
22 changes: 22 additions & 0 deletions tests/bulk/bulkwrite-update_error-009.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
--TEST--
MongoDB\Driver\BulkWrite::update() with multi:true prohibits sort option
--SKIPIF--
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
--FILE--
<?php
require_once __DIR__ . "/../utils/basic.inc";

$manager = create_test_manager();
$bulk = new MongoDB\Driver\BulkWrite;

echo throws(function() use ($manager, $bulk) {
$bulk->update(['x' => ['$gt' => 1]], ['$set' => ['y' => 11]], ['multi' => true, 'sort' => ['x' => 1]]);
}, MongoDB\Driver\Exception\InvalidArgumentException::class), "\n";

?>
===DONE===
<?php exit(0); ?>
--EXPECT--
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
Invalid option 'sort'
===DONE===
Loading