Skip to content

Commit 8406a57

Browse files
committed
There's no active transaction
1 parent c204fe1 commit 8406a57

File tree

4 files changed

+342
-63
lines changed

4 files changed

+342
-63
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -37,25 +37,12 @@ jobs:
3737
os:
3838
- "ubuntu-22.04"
3939
php-version:
40-
- "7.4"
41-
- "8.0"
42-
- "8.1"
43-
- "8.2"
4440
- "8.3"
45-
- "8.4"
4641
dependencies:
4742
- "highest"
4843
extension:
4944
- "pdo_sqlite"
5045
include:
51-
- os: "ubuntu-20.04"
52-
php-version: "7.4"
53-
dependencies: "lowest"
54-
extension: "pdo_sqlite"
55-
- os: "ubuntu-22.04"
56-
php-version: "7.4"
57-
dependencies: "highest"
58-
extension: "sqlite3"
5946
- os: "ubuntu-22.04"
6047
php-version: "8.1"
6148
dependencies: "highest"
@@ -107,17 +94,10 @@ jobs:
10794
strategy:
10895
matrix:
10996
php-version:
110-
- "7.4"
111-
- "8.2"
11297
- "8.3"
11398
oracle-version:
11499
- "21"
115100
- "23"
116-
include:
117-
- php-version: "8.4"
118-
oracle-version: "23"
119-
- php-version: "7.4"
120-
oracle-version: "11"
121101

122102
services:
123103
oracle:
@@ -168,17 +148,10 @@ jobs:
168148
strategy:
169149
matrix:
170150
php-version:
171-
- "7.4"
172-
- "8.2"
173151
- "8.3"
174152
oracle-version:
175153
- "21"
176154
- "23"
177-
include:
178-
- php-version: "8.4"
179-
oracle-version: "23"
180-
- php-version: "7.4"
181-
oracle-version: "11"
182155

183156
services:
184157
oracle:
@@ -238,24 +211,12 @@ jobs:
238211
- "pgsql"
239212
- "pdo_pgsql"
240213
include:
241-
- php-version: "8.2"
242-
postgres-version: "16"
243-
extension: "pgsql"
244214
- php-version: "8.3"
245215
postgres-version: "16"
246216
extension: "pgsql"
247-
- php-version: "8.4"
248-
postgres-version: "16"
249-
extension: "pgsql"
250-
- php-version: "8.2"
251-
postgres-version: "16"
252-
extension: "pdo_pgsql"
253217
- php-version: "8.3"
254218
postgres-version: "16"
255219
extension: "pdo_pgsql"
256-
- php-version: "8.4"
257-
postgres-version: "16"
258-
extension: "pdo_pgsql"
259220

260221
services:
261222
postgres:
@@ -487,22 +448,12 @@ jobs:
487448
strategy:
488449
matrix:
489450
php-version:
490-
- "7.4"
491-
- "8.2"
492451
- "8.3"
493-
- "8.4"
494452
extension:
495453
- "sqlsrv"
496454
- "pdo_sqlsrv"
497455
collation:
498456
- "Latin1_General_100_CI_AS_SC_UTF8"
499-
include:
500-
- collation: "Latin1_General_100_CS_AS_SC_UTF8"
501-
php-version: "7.4"
502-
extension: "sqlsrv"
503-
- collation: "Latin1_General_100_CS_AS_SC_UTF8"
504-
php-version: "7.4"
505-
extension: "pdo_sqlsrv"
506457

507458
services:
508459
mssql:
@@ -555,10 +506,7 @@ jobs:
555506
strategy:
556507
matrix:
557508
php-version:
558-
- "7.4"
559-
- "8.2"
560509
- "8.3"
561-
- "8.4"
562510

563511
services:
564512
ibm_db2:

src/Connection.php

Lines changed: 45 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,16 +1283,39 @@ public function transactional(Closure $func)
12831283

12841284
try {
12851285
$res = $func($this);
1286-
$this->commit();
12871286

12881287
$successful = true;
1289-
1290-
return $res;
12911288
} finally {
12921289
if (! $successful) {
12931290
$this->rollBack();
12941291
}
12951292
}
1293+
1294+
$this->commit();
1295+
// $successful = false;
1296+
// try {
1297+
// $this->commit();
1298+
//
1299+
// $successful = true;
1300+
// } finally {
1301+
// if (! $successful) {
1302+
// $this->rollBack();
1303+
// }
1304+
// }
1305+
1306+
return $res;
1307+
1308+
// try {
1309+
// $res = $func($this);
1310+
// } catch (Throwable $e) {
1311+
// $this->rollBack();
1312+
//
1313+
// throw $e;
1314+
// }
1315+
//
1316+
// $this->commit();
1317+
//
1318+
// return $res;
12961319
}
12971320

12981321
/**
@@ -1424,12 +1447,21 @@ public function commit()
14241447

14251448
$connection = $this->getWrappedConnection();
14261449

1427-
if ($this->transactionNestingLevel === 1) {
1428-
$result = $this->doCommit($connection);
1429-
} elseif ($this->nestTransactionsWithSavepoints) {
1430-
$this->releaseSavepoint($this->_getNestedTransactionSavePointName());
1450+
try {
1451+
if ($this->transactionNestingLevel === 1) {
1452+
$result = $this->doCommit($connection);
1453+
} elseif ($this->nestTransactionsWithSavepoints) {
1454+
$this->releaseSavepoint($this->_getNestedTransactionSavePointName());
1455+
}
1456+
} finally {
1457+
$this->updateTransactionStateAfterCommit();
14311458
}
14321459

1460+
return $result;
1461+
}
1462+
1463+
private function updateTransactionStateAfterCommit(): void
1464+
{
14331465
--$this->transactionNestingLevel;
14341466

14351467
$eventManager = $this->getEventManager();
@@ -1446,12 +1478,10 @@ public function commit()
14461478
}
14471479

14481480
if ($this->autoCommit !== false || $this->transactionNestingLevel !== 0) {
1449-
return $result;
1481+
return;
14501482
}
14511483

14521484
$this->beginTransaction();
1453-
1454-
return $result;
14551485
}
14561486

14571487
/**
@@ -1468,6 +1498,11 @@ private function doCommit(DriverConnection $connection)
14681498
}
14691499

14701500
$result = $connection->commit();
1501+
// try {
1502+
// $result = $connection->commit();
1503+
// } catch (Driver\Exception $e) {
1504+
// throw $this->convertExceptionDuringQuery($e, 'COMMIT');
1505+
// }
14711506

14721507
if ($logger !== null) {
14731508
$logger->stopQuery();

src/Driver/OCI8/Connection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public function beginTransaction(): bool
142142

143143
public function commit(): bool
144144
{
145-
if (! oci_commit($this->connection)) {
145+
if (! @oci_commit($this->connection)) {
146146
throw Error::new($this->connection);
147147
}
148148

0 commit comments

Comments
 (0)