diff --git a/core/lib/Drupal/Core/Cache/DatabaseBackend.php b/core/lib/Drupal/Core/Cache/DatabaseBackend.php index 3a9fb78..86d1c45 100644 --- a/core/lib/Drupal/Core/Cache/DatabaseBackend.php +++ b/core/lib/Drupal/Core/Cache/DatabaseBackend.php @@ -221,11 +221,25 @@ public function setMultiple(array $items) { $values = array(); foreach ($items as $cid => $item) { + // Check if maximum expiration settings for cache bin is defined. If set, + // enforce an upper limit for the expiration to allow for garbage + // collection. + if (isset($this->configuration['max_expire'])) { + $max_expire = $this->configuration['max_expire'] + REQUEST_TIME; + } + else { + $max_expire = Cache::PERMANENT; + } + $item += array( - 'expire' => CacheBackendInterface::CACHE_PERMANENT, + 'expire' => $max_expire, 'tags' => array(), ); + if ($item['expire'] == Cache::PERMANENT || $item['expire'] > $max_expire) { + $item['expire'] = $max_expire; + } + Cache::validateTags($item['tags']); $item['tags'] = array_unique($item['tags']); // Sort the cache tags so that they are stored consistently in the DB.