Skip to content

Commit 86e00c3

Browse files
committed
Always succeed txn if no replicaset
1 parent 3906137 commit 86e00c3

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/Database/Adapter/Mongo.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,9 @@ public function withTransaction(callable $callback): mixed
125125

126126
public function startTransaction(): bool
127127
{
128-
129128
// If the database is not a replica set, we can't use transactions
130129
if (!$this->client->isReplicaSet()) {
131-
return false;
130+
return true;
132131
}
133132

134133
try {
@@ -162,6 +161,11 @@ public function startTransaction(): bool
162161

163162
public function commitTransaction(): bool
164163
{
164+
// If the database is not a replica set, we can't use transactions
165+
if (!$this->client->isReplicaSet()) {
166+
return true;
167+
}
168+
165169
try {
166170
if ($this->inTransaction === 0) {
167171
return false;
@@ -194,6 +198,11 @@ public function commitTransaction(): bool
194198

195199
public function rollbackTransaction(): bool
196200
{
201+
// If the database is not a replica set, we can't use transactions
202+
if (!$this->client->isReplicaSet()) {
203+
return true;
204+
}
205+
197206
try {
198207
if ($this->inTransaction === 0) {
199208
return false;

0 commit comments

Comments
 (0)