Skip to content

allow to configure default_ttl to null #414

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 1 commit into from
Mar 17, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

The change log describes what is "Added", "Removed", "Changed" or "Fixed" between each release.

# 1.26.0 - 2022-03-17

- Fixed you can now configure the cache plugin default_ttl with `null`.

# 1.25.0 - 2021-11-26
- Added PHP 8.1 support
- Added Symfony 6 support
Expand Down
8 changes: 7 additions & 1 deletion src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -713,8 +713,14 @@ private function createCachePluginNode()
->integerNode('cache_lifetime')
->info('The minimum time we should store a cache item')
->end()
->integerNode('default_ttl')
->scalarNode('default_ttl')
->info('The default max age of a Response')
->validate()
->ifTrue(function ($v) {
return null !== $v && !is_int($v);
})
->thenInvalid('default_ttl must be an integer or null, got %s')
->end()
->end()
->arrayNode('blacklisted_paths')
->info('An array of regular expression patterns for paths not to be cached. Defaults to an empty array.')
Expand Down
9 changes: 9 additions & 0 deletions tests/Resources/Fixtures/config/ttl_null.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
httplug:
clients:
test:
plugins:
-
cache:
cache_pool: my_custom_cache_pull
config:
default_ttl: null
33 changes: 33 additions & 0 deletions tests/Unit/DependencyInjection/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -453,4 +453,37 @@ public function testInvalidCapturedBodyLengthString(): void
$this->expectExceptionMessage('The child node "captured_body_length" at path "httplug.profiling" must be an integer or null');
$this->assertProcessedConfigurationEquals([], [$file]);
}

public function testNullDefaultTtl(): void
{
$file = __DIR__.'/../../Resources/Fixtures/config/ttl_null.yml';
$config = $this->emptyConfig;
$config['clients'] = [
'test' => [
'factory' => 'httplug.factory.auto',
'service' => null,
'public' => null,
'flexible_client' => false,
'http_methods_client' => false,
'batch_client' => false,
'config' => [],
'plugins' => [
[
'cache' => [
'config' => [
'default_ttl' => null,
'blacklisted_paths' => [],
'methods' => ['GET', 'HEAD'],
'cache_listeners' => [],
],
'cache_pool' => 'my_custom_cache_pull',
'enabled' => true,
'stream_factory' => 'httplug.stream_factory',
],
],
],
],
];
$this->assertProcessedConfigurationEquals($config, [$file]);
}
}