Skip to content

Commit 2ab7855

Browse files
authored
Merge pull request #5686 from simPod/logging
fix: always log savepoint release
2 parents 116a60f + eebdee3 commit 2ab7855

File tree

1 file changed

+39
-18
lines changed

1 file changed

+39
-18
lines changed

src/Connection.php

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,27 +1336,10 @@ public function commit()
13361336

13371337
$connection = $this->getWrappedConnection();
13381338

1339-
$logger = $this->_config->getSQLLogger();
1340-
13411339
if ($this->transactionNestingLevel === 1) {
1342-
if ($logger !== null) {
1343-
$logger->startQuery('"COMMIT"');
1344-
}
1345-
1346-
$result = $connection->commit();
1347-
1348-
if ($logger !== null) {
1349-
$logger->stopQuery();
1350-
}
1340+
$result = $this->doCommit($connection);
13511341
} elseif ($this->nestTransactionsWithSavepoints) {
1352-
if ($logger !== null) {
1353-
$logger->startQuery('"RELEASE SAVEPOINT"');
1354-
}
1355-
13561342
$this->releaseSavepoint($this->_getNestedTransactionSavePointName());
1357-
if ($logger !== null) {
1358-
$logger->stopQuery();
1359-
}
13601343
}
13611344

13621345
--$this->transactionNestingLevel;
@@ -1372,6 +1355,28 @@ public function commit()
13721355
return $result;
13731356
}
13741357

1358+
/**
1359+
* @return bool
1360+
*
1361+
* @throws DriverException
1362+
*/
1363+
private function doCommit(DriverConnection $connection)
1364+
{
1365+
$logger = $this->_config->getSQLLogger();
1366+
1367+
if ($logger !== null) {
1368+
$logger->startQuery('"COMMIT"');
1369+
}
1370+
1371+
$result = $connection->commit();
1372+
1373+
if ($logger !== null) {
1374+
$logger->stopQuery();
1375+
}
1376+
1377+
return $result;
1378+
}
1379+
13751380
/**
13761381
* Commits all current nesting transactions.
13771382
*
@@ -1475,17 +1480,33 @@ public function createSavepoint($savepoint)
14751480
*/
14761481
public function releaseSavepoint($savepoint)
14771482
{
1483+
$logger = $this->_config->getSQLLogger();
1484+
14781485
$platform = $this->getDatabasePlatform();
14791486

14801487
if (! $platform->supportsSavepoints()) {
14811488
throw ConnectionException::savepointsNotSupported();
14821489
}
14831490

14841491
if (! $platform->supportsReleaseSavepoints()) {
1492+
if ($logger !== null) {
1493+
$logger->stopQuery();
1494+
}
1495+
14851496
return;
14861497
}
14871498

1499+
if ($logger !== null) {
1500+
$logger->startQuery('"RELEASE SAVEPOINT"');
1501+
}
1502+
14881503
$this->executeStatement($platform->releaseSavePoint($savepoint));
1504+
1505+
if ($logger === null) {
1506+
return;
1507+
}
1508+
1509+
$logger->stopQuery();
14891510
}
14901511

14911512
/**

0 commit comments

Comments
 (0)