update driver to 2.1.1

This commit is contained in:
shimon committed 2025-07-23 08:44:38 +03:00
1 parent e9ee5bce62
commit cbe7caad1f
4 files changed
+25 -25

No files matched your search

+1 -1
View File
@@ -13,7 +13,7 @@ RUN composer update --ignore-platform-reqs --optimize-autoloader \
FROM appwrite/utopia-base:php-8.3-0.1.0 as compile
ENV PHP_MONGO_VERSION=1.11.1
ENV PHP_MONGO_VERSION=2.1.1
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
+2 -2
View File
@@ -29,7 +29,7 @@
},
"require": {
"php": ">=8.0",
"ext-mongodb": "*",
"ext-mongodb": "2.1.1",
"mongodb/mongodb": "2.1.0"
},
"require-dev": {
@@ -37,6 +37,6 @@
"phpunit/phpunit": "^9.4",
"swoole/ide-helper": "4.8.0",
"laravel/pint": "1.2.*",
"phpstan/phpstan": "1.8.*"
"phpstan/phpstan": "2.1.*"
}
}
Generated
+12 -13
View File
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "6def0d090ef1b5df4a7d2af3ea71fe1c",
"content-hash": "66c3842bf94f4946d1277b41cf28219d",
"packages": [
{
"name": "mongodb/mongodb",
@@ -648,20 +648,20 @@
},
{
"name": "phpstan/phpstan",
"version": "1.8.11",
"version": "2.1.19",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan.git",
"reference": "46e223dd68a620da18855c23046ddb00940b4014"
"reference": "473a8c30e450d87099f76313edcbb90852f9afdf"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/46e223dd68a620da18855c23046ddb00940b4014",
"reference": "46e223dd68a620da18855c23046ddb00940b4014",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/473a8c30e450d87099f76313edcbb90852f9afdf",
"reference": "473a8c30e450d87099f76313edcbb90852f9afdf",
"shasum": ""
},
"require": {
"php": "^7.2|^8.0"
"php": "^7.4|^8.0"
},
"conflict": {
"phpstan/phpstan-shim": "*"
@@ -686,8 +686,11 @@
"static analysis"
],
"support": {
"docs": "https://phpstan.org/user-guide/getting-started",
"forum": "https://github.com/phpstan/phpstan/discussions",
"issues": "https://github.com/phpstan/phpstan/issues",
"source": "https://github.com/phpstan/phpstan/tree/1.8.11"
"security": "https://github.com/phpstan/phpstan/security/policy",
"source": "https://github.com/phpstan/phpstan-src"
},
"funding": [
{
@@ -697,13 +700,9 @@
{
"url": "https://github.com/phpstan",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan",
"type": "tidelift"
}
],
"time": "2022-10-24T15:45:13+00:00"
"time": "2025-07-21T19:58:24+00:00"
},
{
"name": "phpunit/php-code-coverage",
@@ -2318,7 +2317,7 @@
"prefer-lowest": false,
"platform": {
"php": ">=8.0",
"ext-mongodb": "*"
"ext-mongodb": "2.1.1"
},
"platform-dev": [],
"plugin-api-version": "2.2.0"
+10 -9
View File
@@ -2,7 +2,8 @@
namespace Utopia\Mongo;
use MongoDB\BSON;
use MongoDB\BSON\Document;
use MongoDB\BSON\ObjectId;
use Swoole\Client as SwooleClient;
use Swoole\Coroutine\Client as CoroutineClient;
use stdClass;
@@ -141,7 +142,7 @@ class Client
'$db' => $db ?? $this->database,
]);
$sections = BSON\fromPHP($params);
$sections = Document::fromPHP($params);
$message = pack('V*', 21 + strlen($sections), $this->id, 0, 2013, 0) . "\0" . $sections;
return $this->send($message);
}
@@ -201,11 +202,11 @@ class Client
(!isset($responseLength)) || ($receivedLength < $responseLength)
);
/**
* @var stdClass $result
*/
$result = BSON\toPHP(substr($res, 21, $responseLength - 21));
$bsonString = substr($res, 21, $responseLength - 21);
$result = Document::fromBSON($bsonString)->toPHP();
if (is_array($result)) {
$result = (object) $result;
}
if (property_exists($result, "writeErrors")) {
// Throws Utopia\Mongo\Exception
throw new Exception(
@@ -439,7 +440,7 @@ class Client
$docObj->{$key} = $value;
}
$docObj->_id ??= new BSON\ObjectId();
$docObj->_id ??= new ObjectId();
$this->query(array_merge([
self::COMMAND_INSERT => $collection,
@@ -464,7 +465,7 @@ class Client
$docObj->{$key} = $value;
}
$docObj->_id ??= new BSON\ObjectId();
$docObj->_id ??= new ObjectId();
$docObjs[] = $docObj;
}