Skip to content

Commit 7a1ba05

Browse files
Merge branch '5.4' into 6.0
* 5.4: (22 commits) fix cs Update validators.lv.xlf Fix API gateway service name Improve recommendation message for "composer req" Fix CS in composer.json [DependencyInjection] fix preloading Update validators.uz.xlf AddMake ExpressionVoter Cacheable Add framework config for DBAL cache adapter [ExpressionLanguage] Fix LexerTest number types [Process] intersect with getenv() to populate default envs Improve CI script a bit Fix deprecation message placeholders [Cache] Fix calculate ttl in couchbase sdk 3.0 Fix Loco Provider [Cache] fix dbindex Redis Fix typos in a test message [Cache] fix releasing not acquired locks [DependencyInjection] fix creating 2nd container instances Never rely on dynamic properties ...
2 parents 5de54a5 + 85d50a5 commit 7a1ba05

File tree

7 files changed

+35
-4
lines changed

7 files changed

+35
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ CHANGELOG
4343
* Add support for `statusCode` default parameter when loading a template directly from route using the `Symfony\Bundle\FrameworkBundle\Controller\TemplateController` controller
4444
* Deprecate `translation:update` command, use `translation:extract` instead
4545
* Add `PhpStanExtractor` support for the PropertyInfo component
46+
* Add `cache.adapter.doctrine_dbal` service to replace `cache.adapter.pdo` when a Doctrine DBAL connection is used.
4647

4748
5.3
4849
---

DependencyInjection/Configuration.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,6 +1049,7 @@ private function addCacheSection(ArrayNodeDefinition $rootNode, callable $willBe
10491049
->scalarNode('default_psr6_provider')->end()
10501050
->scalarNode('default_redis_provider')->defaultValue('redis://localhost')->end()
10511051
->scalarNode('default_memcached_provider')->defaultValue('memcached://localhost')->end()
1052+
->scalarNode('default_doctrine_dbal_provider')->defaultValue('database_connection')->end()
10521053
->scalarNode('default_pdo_provider')->defaultValue($willBeAvailable('doctrine/dbal', Connection::class) ? 'database_connection' : null)->end()
10531054
->arrayNode('pools')
10541055
->useAttributeAsKey('name')

DependencyInjection/FrameworkExtension.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
use Symfony\Component\Cache\Adapter\AdapterInterface;
3434
use Symfony\Component\Cache\Adapter\ArrayAdapter;
3535
use Symfony\Component\Cache\Adapter\ChainAdapter;
36+
use Symfony\Component\Cache\Adapter\DoctrineAdapter;
37+
use Symfony\Component\Cache\Adapter\DoctrineDbalAdapter;
3638
use Symfony\Component\Cache\Adapter\TagAwareAdapter;
3739
use Symfony\Component\Cache\DependencyInjection\CachePoolPass;
3840
use Symfony\Component\Cache\Marshaller\DefaultMarshaller;
@@ -2078,6 +2080,14 @@ private function registerCacheConfiguration(array $config, ContainerBuilder $con
20782080
$container->removeDefinition('cache.default_marshaller');
20792081
}
20802082

2083+
if (!class_exists(DoctrineAdapter::class)) {
2084+
$container->removeDefinition('cache.adapter.doctrine');
2085+
}
2086+
2087+
if (!class_exists(DoctrineDbalAdapter::class)) {
2088+
$container->removeDefinition('cache.adapter.doctrine_dbal');
2089+
}
2090+
20812091
$version = new Parameter('container.build_id');
20822092
$container->getDefinition('cache.adapter.apcu')->replaceArgument(2, $version);
20832093
$container->getDefinition('cache.adapter.system')->replaceArgument(2, $version);
@@ -2090,7 +2100,7 @@ private function registerCacheConfiguration(array $config, ContainerBuilder $con
20902100
// Inline any env vars referenced in the parameter
20912101
$container->setParameter('cache.prefix.seed', $container->resolveEnvPlaceholders($container->getParameter('cache.prefix.seed'), true));
20922102
}
2093-
foreach (['doctrine', 'psr6', 'redis', 'memcached', 'pdo'] as $name) {
2103+
foreach (['doctrine', 'psr6', 'redis', 'memcached', 'doctrine_dbal', 'pdo'] as $name) {
20942104
if (isset($config[$name = 'default_'.$name.'_provider'])) {
20952105
$container->setAlias('cache.'.$name, new Alias(CachePoolPass::getServiceProvider($container, $config[$name]), false));
20962106
}

Resources/config/cache.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Component\Cache\Adapter\AdapterInterface;
1717
use Symfony\Component\Cache\Adapter\ApcuAdapter;
1818
use Symfony\Component\Cache\Adapter\ArrayAdapter;
19+
use Symfony\Component\Cache\Adapter\DoctrineDbalAdapter;
1920
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
2021
use Symfony\Component\Cache\Adapter\MemcachedAdapter;
2122
use Symfony\Component\Cache\Adapter\PdoAdapter;
@@ -166,6 +167,23 @@
166167
])
167168
->tag('monolog.logger', ['channel' => 'cache'])
168169

170+
->set('cache.adapter.doctrine_dbal', DoctrineDbalAdapter::class)
171+
->abstract()
172+
->args([
173+
abstract_arg('DBAL connection service'),
174+
'', // namespace
175+
0, // default lifetime
176+
[], // table options
177+
service('cache.default_marshaller')->ignoreOnInvalid(),
178+
])
179+
->call('setLogger', [service('logger')->ignoreOnInvalid()])
180+
->tag('cache.pool', [
181+
'provider' => 'cache.default_doctrine_dbal_provider',
182+
'clearer' => 'cache.default_clearer',
183+
'reset' => 'reset',
184+
])
185+
->tag('monolog.logger', ['channel' => 'cache'])
186+
169187
->set('cache.adapter.pdo', PdoAdapter::class)
170188
->abstract()
171189
->args([

Resources/config/notifier_transports.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
->parent('notifier.transport_factory.abstract')
9797
->tag('texter.transport_factory')
9898

99-
->set('notifier.transport_factory.all-my-sms', AllMySmsTransportFactory::class)
99+
->set('notifier.transport_factory.allmysms', AllMySmsTransportFactory::class)
100100
->parent('notifier.transport_factory.abstract')
101101
->tag('texter.transport_factory')
102102

@@ -168,7 +168,7 @@
168168
->parent('notifier.transport_factory.abstract')
169169
->tag('chatter.transport_factory')
170170

171-
->set('notifier.transport_factory.gateway-api', GatewayApiTransportFactory::class)
171+
->set('notifier.transport_factory.gatewayapi', GatewayApiTransportFactory::class)
172172
->parent('notifier.transport_factory.abstract')
173173
->tag('texter.transport_factory')
174174

Tests/DependencyInjection/ConfigurationTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,7 @@ protected static function getBundleDefaultConfig()
500500
'directory' => '%kernel.cache_dir%/pools/app',
501501
'default_redis_provider' => 'redis://localhost',
502502
'default_memcached_provider' => 'memcached://localhost',
503+
'default_doctrine_dbal_provider' => 'database_connection',
503504
'default_pdo_provider' => ContainerBuilder::willBeAvailable('doctrine/dbal', Connection::class, ['symfony/framework-bundle']) ? 'database_connection' : null,
504505
'prefix_seed' => '_%kernel.project_dir%.%kernel.container_class%',
505506
],

Tests/DependencyInjection/FrameworkExtensionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1873,7 +1873,7 @@ public function testIfNotifierTransportsAreKnownByFrameworkExtension()
18731873

18741874
foreach ((new Finder())->in(\dirname(__DIR__, 4).'/Component/Notifier/Bridge')->directories()->depth(0)->exclude('Mercure') as $bridgeDirectory) {
18751875
$transportFactoryName = strtolower(preg_replace('/(.)([A-Z])/', '$1-$2', $bridgeDirectory->getFilename()));
1876-
$this->assertTrue($container->hasDefinition('notifier.transport_factory.'.$transportFactoryName), sprintf('Did you forget to add the TransportFactory: "%s" to the $classToServices array in the FrameworkBundleExtension?', $bridgeDirectory->getFilename()));
1876+
$this->assertTrue($container->hasDefinition('notifier.transport_factory.'.$transportFactoryName), sprintf('Did you forget to add the "%s" TransportFactory to the $classToServices array in FrameworkExtension?', $bridgeDirectory->getFilename()));
18771877
}
18781878
}
18791879

0 commit comments

Comments
 (0)