Skip to content

Allow respect_cache_headers to be "false" #166

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 12, 2017
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -573,16 +573,19 @@ 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);

return $v;
})
->end()
->validate()
->ifNotInArray([null, true, false])
->thenInvalid('Value for "respect_cache_headers" must be null or boolean')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ifNotInArray does not create a new node in the tree (otherwise it would need an end node too). It configures the validation node. So this one should be unindented (it was right before your last update)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, it was me that misunderstood. Thank you.

->end()
->end()
->variableNode('respect_response_cache_directives')
->info('A list of cache directives to respect when caching responses')
Expand Down
6 changes: 6 additions & 0 deletions Tests/Resources/Fixtures/config/bc/issue-166.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
httplug:
plugins:
cache:
cache_pool: my_cache_pool
config:
respect_cache_headers: false
18 changes: 18 additions & 0 deletions Tests/Unit/DependencyInjection/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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".
Expand Down