Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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,15 +573,18 @@ 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()
Copy link
Contributor

Choose a reason for hiding this comment

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

the end call should be unindented to make the tree structure visual. This is the end of ->beforeNormalization()

->validate()
->ifNotInArray([null, true, false])
Copy link
Contributor

Choose a reason for hiding this comment

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

this one should be indented inside ->validate

Copy link
Member Author

Choose a reason for hiding this comment

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

Thank you

->thenInvalid('Value for "respect_cache_headers" must be null or boolean')
->end()
->end()
->variableNode('respect_response_cache_directives')
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