diff --git a/src/Client.php b/src/Client.php index 72df20acb8..7a20dfd505 100644 --- a/src/Client.php +++ b/src/Client.php @@ -101,7 +101,7 @@ class Client * Commands that don't support readConcern */ private array $readConcernNotSupporteedCommands = [ - self::COMMAND_GET_MORE, + self::COMMAND_GET_MORE, self::COMMAND_KILL_CURSORS ]; @@ -330,7 +330,7 @@ class Client // MongoDB will reject commands with readConcern that have txnNumber but not startTransaction // Or if the command is in the readConcernNotSupporteedCommands array if (((isset($command['txnNumber']) && !isset($command['startTransaction']) && isset($command['readConcern'])) - || + || in_array(array_keys($command)[0] ?? '', $this->readConcernNotSupporteedCommands))) { unset($command['readConcern']); } @@ -2062,4 +2062,4 @@ class Client { $this->close(); } -} \ No newline at end of file +} diff --git a/tests/TransactionTest.php b/tests/TransactionTest.php index 1ae76431d2..b4cb6511cf 100644 --- a/tests/TransactionTest.php +++ b/tests/TransactionTest.php @@ -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]); }