@@ -307,30 +307,10 @@ public function load(array $configs, ContainerBuilder $container)
307
307
}
308
308
}
309
309
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
-
325
310
if ($ this ->isConfigEnabled ($ container , $ config ['request ' ])) {
326
311
$ this ->registerRequestConfiguration ($ config ['request ' ], $ container , $ loader );
327
312
}
328
313
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
-
334
314
if ($ this ->isConfigEnabled ($ container , $ config ['form ' ])) {
335
315
if (!class_exists (Form::class)) {
336
316
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)
459
439
$ this ->registerUidConfiguration ($ config ['uid ' ], $ container , $ loader );
460
440
}
461
441
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
+
462
464
$ this ->addAnnotatedClassesToCompile ([
463
465
'** \\Controller \\' ,
464
466
'** \\Entity \\' ,
0 commit comments