diff --git a/core/lib/Drupal/Core/Cache/RefinableCacheableDependencyInterface.php b/core/lib/Drupal/Core/Cache/RefinableCacheableDependencyInterface.php index 7405fa6..ff9c172 100644 --- a/core/lib/Drupal/Core/Cache/RefinableCacheableDependencyInterface.php +++ b/core/lib/Drupal/Core/Cache/RefinableCacheableDependencyInterface.php @@ -37,9 +37,10 @@ public function addCacheContexts(array $cache_contexts); public function addCacheTags(array $cache_tags); /** - * Sets the maximum age (in seconds). + * Merges the maximum age (in seconds) with the existing maximum age. * - * This only sets the max age if it is lower than the existing one. + * The max age will be set to the given value if it is lower than the existing + * value. * * @param int $max_age * The max age to associate. @@ -49,6 +50,6 @@ public function addCacheTags(array $cache_tags); * @throws \InvalidArgumentException * Thrown if a non-integer value is supplied. */ - public function setCacheMaxAgeIfLower($max_age); + public function mergeCacheMaxAge($max_age); } diff --git a/core/lib/Drupal/Core/Cache/RefinableCacheableDependencyTrait.php b/core/lib/Drupal/Core/Cache/RefinableCacheableDependencyTrait.php index d98e08d..972a829 100644 --- a/core/lib/Drupal/Core/Cache/RefinableCacheableDependencyTrait.php +++ b/core/lib/Drupal/Core/Cache/RefinableCacheableDependencyTrait.php @@ -52,7 +52,7 @@ public function addCacheTags(array $cache_tags) { /** * {@inheritdoc} */ - public function setCacheMaxAgeIfLower($max_age) { + public function mergeCacheMaxAge($max_age) { $this->cacheMaxAge = Cache::mergeMaxAges($this->cacheMaxAge, $max_age); return $this; } diff --git a/core/modules/views_ui/src/ViewUI.php b/core/modules/views_ui/src/ViewUI.php index 48dc778..792898a 100644 --- a/core/modules/views_ui/src/ViewUI.php +++ b/core/modules/views_ui/src/ViewUI.php @@ -1346,8 +1346,8 @@ public function addCacheContexts(array $cache_contexts) { /** * {@inheritdoc} */ - public function setCacheMaxAgeIfLower($max_age) { - return $this->storage->setCacheMaxAgeIfLower($max_age); + public function mergeCacheMaxAge($max_age) { + return $this->storage->mergeCacheMaxAge($max_age); } /** diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php index 16a5700..d58c054 100644 --- a/core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php @@ -528,7 +528,7 @@ public function testCacheContexts() { /** * @covers ::getCacheMaxAge - * @covers ::setCacheMaxAgeIfLower + * @covers ::mergeCacheMaxAge */ public function testCacheMaxAge() { // Cache max age is permanent by default. @@ -536,8 +536,8 @@ public function testCacheMaxAge() { // Set two cache max ages, the lower value is the one that needs to be // returned. - $this->entity->setCacheMaxAgeIfLower(600); - $this->entity->setCacheMaxAgeIfLower(1800); + $this->entity->mergeCacheMaxAge(600); + $this->entity->mergeCacheMaxAge(1800); $this->assertEquals(600, $this->entity->getCacheMaxAge()); }