Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6e54976

Browse filesBrowse files
bug #43164 [FrameworkBundle] Fix cache pool configuration with one adapter and one provider (fancyweb)
This PR was merged into the 4.4 branch. Discussion ---------- [FrameworkBundle] Fix cache pool configuration with one adapter and one provider | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - My current YAML config is: ```yaml framework: cache: pools: app.cache.redis: adapter: "cache.adapter.redis" provider: "%env(REDIS_URL)%/4" default_lifetime: 86400 ``` I'm trying to migrate it to PHP with the new config builder system. The problem is that `->adapter('cache.adapter.redis')` does not exist in the generated config class since `adapter` is just a shortcut in the first place. So I have to use `->adapters(['cache.adapter.redis'])` but the configuration doesn't allow it. The difference with this patch is that we allow the case where `adapters` is a map that contains only one item and `provider` is set. The result is exactly the same and it becomes compatible with the config class. I added an extra check for DX to avoid an `\ErrorException` if `adapters` is not an array. Commits ------- 863dd5e [FrameworkBundle] Fix cache pool configuration with one adapter and one provider
2 parents ac3631a + 863dd5e commit 6e54976
Copy full SHA for 6e54976

File tree

1 file changed

+3
-2
lines changed
Filter options

1 file changed

+3
-2
lines changed

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,13 +1012,14 @@ private function addCacheSection(ArrayNodeDefinition $rootNode)
10121012
->prototype('array')
10131013
->fixXmlConfig('adapter')
10141014
->beforeNormalization()
1015-
->ifTrue(function ($v) { return (isset($v['adapters']) || \is_array($v['adapter'] ?? null)) && isset($v['provider']); })
1016-
->thenInvalid('Pool cannot have a "provider" while "adapter" is set to a map')
1015+
->ifTrue(function ($v) { return isset($v['provider']) && \is_array($v['adapters'] ?? $v['adapter'] ?? null) && 1 < \count($v['adapters'] ?? $v['adapter']); })
1016+
->thenInvalid('Pool cannot have a "provider" while more than one adapter is defined')
10171017
->end()
10181018
->children()
10191019
->arrayNode('adapters')
10201020
->performNoDeepMerging()
10211021
->info('One or more adapters to chain for creating the pool, defaults to "cache.app".')
1022+
->beforeNormalization()->castToArray()->end()
10221023
->beforeNormalization()
10231024
->always()->then(function ($values) {
10241025
if ([0] === array_keys($values) && \is_array($values[0])) {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.