Merge branch 'main' of github.com:utopia-php/mongo into feat-mongo-transactions

# Conflicts:
#	composer.lock
#	src/Client.php
This commit is contained in:
shimon committed 2025-07-24 23:15:02 +03:00
commit 68dcddf5f2
2 files changed
+15 -2

No files matched your search

+1 -1
View File
@@ -218,7 +218,7 @@ class Auth
/**
* @return string
*/
public function getCnonce(): string
public function getCnonce(): ?string
{
return $this->cnonce;
}
+14 -1
View File
@@ -202,6 +202,19 @@ class Client
(!isset($responseLength)) || ($receivedLength < $responseLength)
);
/*
* The first 21 bytes of the MongoDB wire protocol response consist of:
* - 16 bytes: Standard message header, which includes:
* - messageLength (4 bytes): Total size of the message, including the header.
* - requestID (4 bytes): Identifier for this message.
* - responseTo (4 bytes): The requestID that this message is responding to.
* - opCode (4 bytes): The operation code for the message type (e.g., OP_MSG).
* - 4 bytes: flagBits, which provide additional information about the message.
* - 1 byte: payloadType, indicating the type of the following payload (usually 0 for a BSON document).
*
* These 21 bytes are protocol metadata and precede the actual BSON-encoded document in the response.
*/
$bsonString = substr($res, 21, $responseLength - 21);
$result = Document::fromBSON($bsonString)->toPHP();
if (is_array($result)) {
@@ -563,7 +576,7 @@ class Client
$updateOperation = [
'q' => $op['filter'],
'u' => $cleanUpdate,
'u' => $this->toObject($cleanUpdate),
'upsert' => true,
'multi' => isset($op['multi']) ? $op['multi'] : false,
];