Skip to content

Commit

Permalink
allow not explicitly enabling savepoints with DBAL 4 (#282)
Browse files Browse the repository at this point in the history
  • Loading branch information
dmaicher authored Feb 15, 2024
1 parent 7111718 commit f10de29
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ return [
];
```

3. Starting from version 8 you need to make sure you have `use_savepoints` enabled on your doctrine DBAL configuration for all relevant connections:
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:

```yaml
doctrine:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use DAMA\DoctrineTestBundle\Doctrine\Cache\Psr6StaticArrayCache;
use DAMA\DoctrineTestBundle\Doctrine\DBAL\Middleware;
use Doctrine\Common\Cache\Cache;
use Doctrine\DBAL\Connection;
use Psr\Cache\CacheItemPoolInterface;
use Symfony\Component\DependencyInjection\ChildDefinition;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
Expand Down Expand Up @@ -179,6 +180,11 @@ private function validateConnectionNames(array $configNames, array $existingName

private function hasSavepointsEnabled(Definition $connectionDefinition): bool
{
// DBAL 4 implicitly always enables savepoints
if (!method_exists(Connection::class, 'getEventManager')) {
return true;
}

foreach ($connectionDefinition->getMethodCalls() as $call) {
if ($call[0] === 'setNestTransactionsWithSavepoints' && isset($call[1][0]) && $call[1][0]) {
return true;
Expand Down

0 comments on commit f10de29

Please sign in to comment.