mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
Merge pull request #31 from utopia-php/exclude-read-concern-commands
Exclude read concern commands
This commit is contained in:
2 files changed
+18
-6
No files matched your search
+18
-2
@@ -66,7 +66,7 @@ class Client
|
||||
public const COMMAND_END_SESSIONS = "endSessions";
|
||||
public const COMMAND_LIST_INDEXES = "listIndexes";
|
||||
public const COMMAND_COLLMOD = "collMod";
|
||||
|
||||
public const COMMAND_KILL_CURSORS = "killCursors";
|
||||
// Connection and performance settings
|
||||
private int $defaultMaxTimeMS = 30000; // 30 seconds default
|
||||
|
||||
@@ -97,6 +97,14 @@ class Client
|
||||
public const READ_PREFERENCE_SECONDARY_PREFERRED = 'secondaryPreferred';
|
||||
public const READ_PREFERENCE_NEAREST = 'nearest';
|
||||
|
||||
/**
|
||||
* Commands that do not support readConcern options
|
||||
*/
|
||||
private array $readConcernNotSupportedCommands = [
|
||||
self::COMMAND_GET_MORE,
|
||||
self::COMMAND_KILL_CURSORS
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* Authentication for connection
|
||||
@@ -320,7 +328,15 @@ class Client
|
||||
|
||||
// CRITICAL: Remove readConcern from any non-first operation in a transaction
|
||||
// MongoDB will reject commands with readConcern that have txnNumber but not startTransaction
|
||||
if (isset($command['txnNumber']) && !isset($command['startTransaction']) && isset($command['readConcern'])) {
|
||||
// Or if the command is in the readConcernNotSupportedCommands array
|
||||
if (
|
||||
(
|
||||
isset($command['txnNumber'])
|
||||
&& !isset($command['startTransaction'])
|
||||
&& isset($command['readConcern'])
|
||||
)
|
||||
|| \in_array(array_key_first($command) ?? '', $this->readConcernNotSupportedCommands)
|
||||
) {
|
||||
unset($command['readConcern']);
|
||||
}
|
||||
|
||||
|
||||
@@ -162,7 +162,6 @@ class TransactionTest extends TestCase
|
||||
// Verify final state
|
||||
$finalState = $client->getSessionState($session);
|
||||
$this->assertEquals('committed', $finalState['state']);
|
||||
|
||||
} finally {
|
||||
$client->endSessions([$session]);
|
||||
}
|
||||
@@ -202,7 +201,6 @@ class TransactionTest extends TestCase
|
||||
// Verify document was not inserted (transaction rolled back)
|
||||
$found = $client->find('test_collection', ['name' => 'abort_test']);
|
||||
$this->assertEmpty($found->cursor->firstBatch);
|
||||
|
||||
} finally {
|
||||
$client->endSessions([$session]);
|
||||
}
|
||||
@@ -251,7 +249,6 @@ class TransactionTest extends TestCase
|
||||
|
||||
$this->assertNotEmpty($found1->cursor->firstBatch);
|
||||
$this->assertNotEmpty($found2->cursor->firstBatch);
|
||||
|
||||
} finally {
|
||||
$client->endSessions([$session]);
|
||||
}
|
||||
@@ -343,7 +340,6 @@ class TransactionTest extends TestCase
|
||||
$this->assertEquals(1, $count);
|
||||
|
||||
$client->commitTransaction($session);
|
||||
|
||||
} finally {
|
||||
$client->endSessions([$session]);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user