Skip to content

Commit 6096905

Browse files
authored
Allow respect_cache_headers to be "false" (#166)
* respect_cache_headers does not allow "false" * Added config file * Use ScalarNode instead of enum * Use built in check * Fixed indentation * fix
1 parent 356aff0 commit 6096905

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

DependencyInjection/Configuration.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -573,16 +573,19 @@ private function createCachePluginNode()
573573
->end()
574574
->end()
575575
->end()
576-
->enumNode('respect_cache_headers')
576+
->scalarNode('respect_cache_headers')
577577
->info('Whether we should care about cache headers or not [DEPRECATED]')
578-
->values([null, true, false])
579578
->beforeNormalization()
580579
->always(function ($v) {
581580
@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);
582581

583582
return $v;
584583
})
585584
->end()
585+
->validate()
586+
->ifNotInArray([null, true, false])
587+
->thenInvalid('Value for "respect_cache_headers" must be null or boolean')
588+
->end()
586589
->end()
587590
->variableNode('respect_response_cache_directives')
588591
->info('A list of cache directives to respect when caching responses')
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
httplug:
2+
plugins:
3+
cache:
4+
cache_pool: my_cache_pool
5+
config:
6+
respect_cache_headers: false

Tests/Unit/DependencyInjection/ConfigurationTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,24 @@ public function testCacheConfigDeprecationCompatibility()
328328
$this->assertProcessedConfigurationEquals($config, [$file]);
329329
}
330330

331+
/**
332+
* @group legacy
333+
*/
334+
public function testCacheConfigDeprecationCompatibilityIssue166()
335+
{
336+
$file = __DIR__.'/../../Resources/Fixtures/config/bc/issue-166.yml';
337+
$config = $this->emptyConfig;
338+
$config['plugins']['cache'] = array_merge($config['plugins']['cache'], [
339+
'enabled' => true,
340+
'cache_pool' => 'my_cache_pool',
341+
'config' => [
342+
'methods' => ['GET', 'HEAD'],
343+
'respect_cache_headers' => false,
344+
],
345+
]);
346+
$this->assertProcessedConfigurationEquals($config, [$file]);
347+
}
348+
331349
/**
332350
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
333351
* @expectedExceptionMessage Can't configure both "toolbar" and "profiling" section. The "toolbar" config is deprecated as of version 1.3.0, please only use "profiling".

0 commit comments

Comments
 (0)