From 937f620ab8a1ec1819e82ab6f592f93a5951e10e Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Thu, 11 May 2017 16:10:44 +0200 Subject: [PATCH 1/6] respect_cache_headers does not allow "false" --- .../DependencyInjection/ConfigurationTest.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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". From 70fad0b1baad101fd4f12b9040d019d43e968681 Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Thu, 11 May 2017 16:14:08 +0200 Subject: [PATCH 2/6] Added config file --- Tests/Resources/Fixtures/config/bc/issue-166.yml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 Tests/Resources/Fixtures/config/bc/issue-166.yml 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 From 156160a0e4876b8b88c78af9bb4945eed0604d94 Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Fri, 12 May 2017 11:06:41 +0200 Subject: [PATCH 3/6] Use ScalarNode instead of enum --- DependencyInjection/Configuration.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index f9a2ea85..a5809d71 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,12 @@ private function createCachePluginNode() return $v; }) ->end() + ->validate() + ->ifTrue(function ($v) { + return !in_array($v, [null, true, false]); + }) + ->thenInvalid('Invalid value for respect_cache_headers: %s. Must be "null", "true" or "false"') + ->end() ->end() ->variableNode('respect_response_cache_directives') ->info('A list of cache directives to respect when caching responses') From b70c886d95f818565ee53ac49540451cb8603b24 Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Fri, 12 May 2017 11:17:46 +0200 Subject: [PATCH 4/6] Use built in check --- DependencyInjection/Configuration.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index a5809d71..97dab104 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -581,12 +581,10 @@ private function createCachePluginNode() return $v; }) - ->end() + ->end() ->validate() - ->ifTrue(function ($v) { - return !in_array($v, [null, true, false]); - }) - ->thenInvalid('Invalid value for respect_cache_headers: %s. Must be "null", "true" or "false"') + ->ifNotInArray([null, true, false]) + ->thenInvalid('Value for "respect_cache_headers" must be null or boolean') ->end() ->end() ->variableNode('respect_response_cache_directives') From 8caee027b3dbfe017d621c07e86f8fb760d189d7 Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Fri, 12 May 2017 12:07:26 +0200 Subject: [PATCH 5/6] Fixed indentation --- DependencyInjection/Configuration.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 97dab104..d0b844aa 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -581,10 +581,10 @@ private function createCachePluginNode() return $v; }) - ->end() + ->end() ->validate() - ->ifNotInArray([null, true, false]) - ->thenInvalid('Value for "respect_cache_headers" must be null or boolean') + ->ifNotInArray([null, true, false]) + ->thenInvalid('Value for "respect_cache_headers" must be null or boolean') ->end() ->end() ->variableNode('respect_response_cache_directives') From 9c8511fdf511c45463b49471df3dda188d888fd0 Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Fri, 12 May 2017 12:16:10 +0200 Subject: [PATCH 6/6] fix --- DependencyInjection/Configuration.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index d0b844aa..00ebe74f 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -584,7 +584,7 @@ private function createCachePluginNode() ->end() ->validate() ->ifNotInArray([null, true, false]) - ->thenInvalid('Value for "respect_cache_headers" must be null or boolean') + ->thenInvalid('Value for "respect_cache_headers" must be null or boolean') ->end() ->end() ->variableNode('respect_response_cache_directives')