diff --git a/README.md b/README.md index 3fd4f0d..b047de8 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/src/DAMA/DoctrineTestBundle/DependencyInjection/DoctrineTestCompilerPass.php b/src/DAMA/DoctrineTestBundle/DependencyInjection/DoctrineTestCompilerPass.php index ce631e6..9e7d79d 100644 --- a/src/DAMA/DoctrineTestBundle/DependencyInjection/DoctrineTestCompilerPass.php +++ b/src/DAMA/DoctrineTestBundle/DependencyInjection/DoctrineTestCompilerPass.php @@ -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; @@ -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;