Skip to content

Commit ad24c1b

Browse files
[FrameworkBundle] define doctrine as default_pdo_provider only if the package is installed
1 parent e519fb0 commit ad24c1b

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

DependencyInjection/Configuration.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Doctrine\Common\Annotations\Annotation;
1515
use Doctrine\Common\Cache\Cache;
16+
use Doctrine\DBAL\Connection;
1617
use Symfony\Bundle\FullStack;
1718
use Symfony\Component\Asset\Package;
1819
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
@@ -882,7 +883,7 @@ private function addCacheSection(ArrayNodeDefinition $rootNode)
882883
->scalarNode('default_psr6_provider')->end()
883884
->scalarNode('default_redis_provider')->defaultValue('redis://localhost')->end()
884885
->scalarNode('default_memcached_provider')->defaultValue('memcached://localhost')->end()
885-
->scalarNode('default_pdo_provider')->defaultValue('doctrine.dbal.default_connection')->end()
886+
->scalarNode('default_pdo_provider')->defaultValue(class_exists(Connection::class) ? 'database_connection' : null)->end()
886887
->arrayNode('pools')
887888
->useAttributeAsKey('name')
888889
->prototype('array')

Tests/DependencyInjection/ConfigurationTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection;
1313

14+
use Doctrine\DBAL\Connection;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Configuration;
1617
use Symfony\Bundle\FullStack;
@@ -268,7 +269,7 @@ protected static function getBundleDefaultConfig()
268269
'directory' => '%kernel.cache_dir%/pools',
269270
'default_redis_provider' => 'redis://localhost',
270271
'default_memcached_provider' => 'memcached://localhost',
271-
'default_pdo_provider' => 'doctrine.dbal.default_connection',
272+
'default_pdo_provider' => class_exists(Connection::class) ? 'database_connection' : null,
272273
),
273274
'workflows' => array(
274275
'enabled' => false,

0 commit comments

Comments
 (0)