diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index f9a2ea85..00ebe74f 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -573,9 +573,8 @@ private function createCachePluginNode() ->end() ->end() ->end() - ->enumNode('respect_cache_headers') + ->scalarNode('respect_cache_headers') ->info('Whether we should care about cache headers or not [DEPRECATED]') - ->values([null, true, false]) ->beforeNormalization() ->always(function ($v) { @trigger_error('The option "respect_cache_headers" is deprecated since version 1.3 and will be removed in 2.0. Use "respect_response_cache_directives" instead.', E_USER_DEPRECATED); @@ -583,6 +582,10 @@ private function createCachePluginNode() return $v; }) ->end() + ->validate() + ->ifNotInArray([null, true, false]) + ->thenInvalid('Value for "respect_cache_headers" must be null or boolean') + ->end() ->end() ->variableNode('respect_response_cache_directives') ->info('A list of cache directives to respect when caching responses') diff --git a/Tests/Resources/Fixtures/config/bc/issue-166.yml b/Tests/Resources/Fixtures/config/bc/issue-166.yml new file mode 100644 index 00000000..ca9d0dff --- /dev/null +++ b/Tests/Resources/Fixtures/config/bc/issue-166.yml @@ -0,0 +1,6 @@ +httplug: + plugins: + cache: + cache_pool: my_cache_pool + config: + respect_cache_headers: false diff --git a/Tests/Unit/DependencyInjection/ConfigurationTest.php b/Tests/Unit/DependencyInjection/ConfigurationTest.php index a5e5758b..0978cb8d 100644 --- a/Tests/Unit/DependencyInjection/ConfigurationTest.php +++ b/Tests/Unit/DependencyInjection/ConfigurationTest.php @@ -328,6 +328,24 @@ public function testCacheConfigDeprecationCompatibility() $this->assertProcessedConfigurationEquals($config, [$file]); } + /** + * @group legacy + */ + public function testCacheConfigDeprecationCompatibilityIssue166() + { + $file = __DIR__.'/../../Resources/Fixtures/config/bc/issue-166.yml'; + $config = $this->emptyConfig; + $config['plugins']['cache'] = array_merge($config['plugins']['cache'], [ + 'enabled' => true, + 'cache_pool' => 'my_cache_pool', + 'config' => [ + 'methods' => ['GET', 'HEAD'], + 'respect_cache_headers' => false, + ], + ]); + $this->assertProcessedConfigurationEquals($config, [$file]); + } + /** * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException * @expectedExceptionMessage Can't configure both "toolbar" and "profiling" section. The "toolbar" config is deprecated as of version 1.3.0, please only use "profiling".