Skip to content

Commit

Permalink
Breaking change: Configuration key "cacheLifetime" has precedence
Browse files Browse the repository at this point in the history
  • Loading branch information
cundd committed Jun 5, 2024
1 parent c426237 commit de0c913
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
8 changes: 4 additions & 4 deletions Classes/Cache/CacheFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ private function getCacheLifetime(
return $cacheLifetime;
}

$cacheLifetime = $configurationProvider->getSetting('cacheLifeTime');
if ($cacheLifetime !== null) {
$cacheLifetime = $configurationProvider->getSetting('cacheLifetime');
if ($cacheLifetime !== null && is_numeric($cacheLifetime) && $cacheLifetime > -1) {
return (int)$cacheLifetime;
}

$cacheLifetime = $configurationProvider->getSetting('cacheLifetime');
if ($cacheLifetime !== null) {
$cacheLifetime = $configurationProvider->getSetting('cacheLifeTime');
if ($cacheLifetime !== null && is_numeric($cacheLifetime) && $cacheLifetime > -1) {
return (int)$cacheLifetime;
}

Expand Down
7 changes: 4 additions & 3 deletions Classes/Configuration/AbstractConfigurationProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,13 +248,14 @@ private function preparePath(array $configuration, string $path): array
*/
private function detectCacheLifetimeConfiguration(array $configuration): int
{
if (isset($configuration['cacheLifeTime']) && is_numeric($configuration['cacheLifeTime'])) {
return (int)$configuration['cacheLifeTime'];
}
if (isset($configuration['cacheLifetime']) && is_numeric($configuration['cacheLifetime'])) {
return (int)$configuration['cacheLifetime'];
}

if (isset($configuration['cacheLifeTime']) && is_numeric($configuration['cacheLifeTime'])) {
return (int)$configuration['cacheLifeTime'];
}

return -1;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ abstract class AbstractConfigurationProviderCase extends TestCase
*/
protected $fixture;

public function setUp(): void
public function setup(): void
{
parent::setUp();
parent::setup();

$settings = [
'paths' => [
Expand Down Expand Up @@ -64,11 +64,12 @@ public function setUp(): void
/**
* @return ConfigurationProviderInterface|TypoScriptConfigurationProvider|StandaloneConfigurationProvider
*/
abstract function getConfigurationProviderToTest();
abstract public function getConfigurationProviderToTest();

public function tearDown(): void
{
unset($this->fixture);
parent::tearDown();
}

/**
Expand All @@ -95,6 +96,7 @@ public function getConfiguredResourceTypesTest()
'vendor-my_other_ext-my_model2' => [
'path' => 'vendor-my_other_ext-my_model2',
'cacheLifetime' => 3,
'cacheLifeTime' => 200, // the key "cacheLifetime" must have precedence
],
],
]
Expand Down

0 comments on commit de0c913

Please sign in to comment.