Skip to content

Commit f10de29

Browse files
authored
allow not explicitly enabling savepoints with DBAL 4 (#282)
1 parent 7111718 commit f10de29

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ return [
3131
];
3232
```
3333

34-
3. Starting from version 8 you need to make sure you have `use_savepoints` enabled on your doctrine DBAL configuration for all relevant connections:
34+
3. Starting from version 8 **and only when using DBAL < 4** you need to make sure you have `use_savepoints` enabled on your doctrine DBAL configuration for all relevant connections:
3535

3636
```yaml
3737
doctrine:

src/DAMA/DoctrineTestBundle/DependencyInjection/DoctrineTestCompilerPass.php

+6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use DAMA\DoctrineTestBundle\Doctrine\Cache\Psr6StaticArrayCache;
66
use DAMA\DoctrineTestBundle\Doctrine\DBAL\Middleware;
77
use Doctrine\Common\Cache\Cache;
8+
use Doctrine\DBAL\Connection;
89
use Psr\Cache\CacheItemPoolInterface;
910
use Symfony\Component\DependencyInjection\ChildDefinition;
1011
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
@@ -179,6 +180,11 @@ private function validateConnectionNames(array $configNames, array $existingName
179180

180181
private function hasSavepointsEnabled(Definition $connectionDefinition): bool
181182
{
183+
// DBAL 4 implicitly always enables savepoints
184+
if (!method_exists(Connection::class, 'getEventManager')) {
185+
return true;
186+
}
187+
182188
foreach ($connectionDefinition->getMethodCalls() as $call) {
183189
if ($call[0] === 'setNestTransactionsWithSavepoints' && isset($call[1][0]) && $call[1][0]) {
184190
return true;

0 commit comments

Comments
 (0)