Skip to content

Commit 01640e8

Browse files
bug #44998 [FrameworkBundle] Allow default cache pools to be overwritten by user (Seldaek)
This PR was merged into the 5.3 branch. Discussion ---------- [FrameworkBundle] Allow default cache pools to be overwritten by user | Q | A | ------------- | --- | Branch? | 5.3 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fixes #44984 | License | MIT | Doc PR | symfony/symfony-docs#... <!-- required for new features --> <!-- Replace this notice by a short README for your feature/bugfix. This will help reviewers and should be a good start for the documentation. Additionally (see https://symfony.com/releases): - Always add tests and ensure they pass. - Bug fixes must be submitted against the lowest maintained branch where they apply (lowest branches are regularly merged to upper ones so they get the fixes too.) - Features and deprecations must be submitted against the latest branch. - Changelog entry should follow https://symfony.com/doc/current/contributing/code/conventions.html#writing-a-changelog-entry - Never break backward compatibility (see https://symfony.com/bc). --> Commits ------- cc7cf5a [FrameworkBundle] Allow default cache pools to be overwritten by user
2 parents bf75321 + cc7cf5a commit 01640e8

File tree

1 file changed

+22
-20
lines changed

1 file changed

+22
-20
lines changed

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

+22-20
Original file line numberDiff line numberDiff line change
@@ -307,30 +307,10 @@ public function load(array $configs, ContainerBuilder $container)
307307
}
308308
}
309309

310-
// register cache before session so both can share the connection services
311-
$this->registerCacheConfiguration($config['cache'], $container);
312-
313-
if ($this->isConfigEnabled($container, $config['session'])) {
314-
if (!\extension_loaded('session')) {
315-
throw new LogicException('Session support cannot be enabled as the session extension is not installed. See https://php.net/session.installation for instructions.');
316-
}
317-
318-
$this->sessionConfigEnabled = true;
319-
$this->registerSessionConfiguration($config['session'], $container, $loader);
320-
if (!empty($config['test'])) {
321-
$container->getDefinition('test.session.listener')->setArgument(1, '%session.storage.options%');
322-
}
323-
}
324-
325310
if ($this->isConfigEnabled($container, $config['request'])) {
326311
$this->registerRequestConfiguration($config['request'], $container, $loader);
327312
}
328313

329-
if (null === $config['csrf_protection']['enabled']) {
330-
$config['csrf_protection']['enabled'] = $this->sessionConfigEnabled && !class_exists(FullStack::class) && ContainerBuilder::willBeAvailable('symfony/security-csrf', CsrfTokenManagerInterface::class, ['symfony/framework-bundle']);
331-
}
332-
$this->registerSecurityCsrfConfiguration($config['csrf_protection'], $container, $loader);
333-
334314
if ($this->isConfigEnabled($container, $config['form'])) {
335315
if (!class_exists(Form::class)) {
336316
throw new LogicException('Form support cannot be enabled as the Form component is not installed. Try running "composer require symfony/form".');
@@ -459,6 +439,28 @@ public function load(array $configs, ContainerBuilder $container)
459439
$this->registerUidConfiguration($config['uid'], $container, $loader);
460440
}
461441

442+
// register cache & dependencies last so that user-defined cache pools take precedence over the default pools created above (e.g. in rate_limiter, validation)
443+
$this->registerCacheConfiguration($config['cache'], $container);
444+
445+
// register session after cache so both can share the connection services
446+
if ($this->isConfigEnabled($container, $config['session'])) {
447+
if (!\extension_loaded('session')) {
448+
throw new LogicException('Session support cannot be enabled as the session extension is not installed. See https://php.net/session.installation for instructions.');
449+
}
450+
451+
$this->sessionConfigEnabled = true;
452+
$this->registerSessionConfiguration($config['session'], $container, $loader);
453+
if (!empty($config['test'])) {
454+
$container->getDefinition('test.session.listener')->setArgument(1, '%session.storage.options%');
455+
}
456+
}
457+
458+
// csrf depends on session being registered
459+
if (null === $config['csrf_protection']['enabled']) {
460+
$config['csrf_protection']['enabled'] = $this->sessionConfigEnabled && !class_exists(FullStack::class) && ContainerBuilder::willBeAvailable('symfony/security-csrf', CsrfTokenManagerInterface::class, ['symfony/framework-bundle']);
461+
}
462+
$this->registerSecurityCsrfConfiguration($config['csrf_protection'], $container, $loader);
463+
462464
$this->addAnnotatedClassesToCompile([
463465
'**\\Controller\\',
464466
'**\\Entity\\',

0 commit comments

Comments
 (0)