diff --git a/core/lib/Drupal/Core/Cache/ApcuBackend.php b/core/lib/Drupal/Core/Cache/ApcuBackend.php index 50fb0fd..b42a053 100644 --- a/core/lib/Drupal/Core/Cache/ApcuBackend.php +++ b/core/lib/Drupal/Core/Cache/ApcuBackend.php @@ -45,20 +45,11 @@ class ApcuBackend implements CacheBackendInterface { protected $invalidationsTagsPrefix; /** - * Prefix for keys holding invalidation cache tags. - * - * Includes the site-specific prefix in $sitePrefix. - * - * @var string - */ - protected $deletionsTagsPrefix; - - /** * A static cache of all tags checked during the request. * * @var array */ - protected static $tagCache = array('deletions' => array(), 'invalidations' => array()); + protected static $tagCache = array(); /** * Constructs a new ApcuBackend instance. @@ -73,7 +64,6 @@ public function __construct($bin, $site_prefix) { $this->sitePrefix = $site_prefix; $this->binPrefix = $this->sitePrefix . '::' . $this->bin . '::'; $this->invalidationsTagsPrefix = $this->sitePrefix . '::itags::'; - $this->deletionsTagsPrefix = $this->sitePrefix . '::dtags::'; } /** @@ -165,16 +155,11 @@ protected function prepareItem($cache, $allow_invalid) { $cache->tags = $cache->tags ? explode(' ', $cache->tags) : array(); $checksum = $this->checksumTags($cache->tags); - // Check if deleteTags() has been called with any of the entry's tags. - if ($cache->checksum_deletions != $checksum['deletions']) { - return FALSE; - } - // Check expire time. $cache->valid = $cache->expire == Cache::PERMANENT || $cache->expire >= REQUEST_TIME; // Check if invalidateTags() has been called with any of the entry's tags. - if ($cache->checksum_invalidations != $checksum['invalidations']) { + if ($cache->checksum_invalidations != $checksum) { $cache->valid = FALSE; } @@ -197,8 +182,7 @@ public function set($cid, $data, $expire = CacheBackendInterface::CACHE_PERMANEN $cache->expire = $expire; $cache->tags = implode(' ', $tags); $checksum = $this->checksumTags($tags); - $cache->checksum_invalidations = $checksum['invalidations']; - $cache->checksum_deletions = $checksum['deletions']; + $cache->checksum_invalidations = $checksum; // APC serializes/unserializes any structure itself. $cache->serialized = 0; $cache->data = $data; @@ -286,18 +270,6 @@ public function invalidateAll() { /** * {@inheritdoc} */ - public function deleteTags(array $tags) { - foreach ($tags as $tag) { - apc_inc($this->deletionsTagsPrefix . $tag, 1, $success); - if (!$success) { - apc_store($this->deletionsTagsPrefix . $tag, 1); - } - } - } - - /** - * {@inheritdoc} - */ public function invalidateTags(array $tags) { foreach ($tags as $tag) { apc_inc($this->invalidationsTagsPrefix . $tag, 1, $success); @@ -317,28 +289,24 @@ public function invalidateTags(array $tags) { * Sum of all invalidations. */ protected function checksumTags(array $tags) { - $checksum = array('invalidations' => 0, 'deletions' => 0); - $query_tags = array('invalidations' => array(), 'deletions' => array()); + $checksum = 0; + $query_tags = array(); foreach ($tags as $tag) { - foreach (array('deletions', 'invalidations') as $type) { - if (isset(static::$tagCache[$type][$tag])) { - $checksum[$type] += static::$tagCache[$type][$tag]; + if (isset(static::$tagCache[$tag])) { + $checksum += static::$tagCache[$tag]; } else { - $query_tags[$type][] = $this->{$type . 'TagsPrefix'} . $tag; + $query_tags[] = $this->invalidationsTagsPrefix . $tag; } - } } - foreach (array('deletions', 'invalidations') as $type) { - if ($query_tags[$type]) { - $result = apc_fetch($query_tags[$type]); + if ($query_tags) { + $result = apc_fetch($query_tags); if ($result) { - static::$tagCache[$type] = array_merge(static::$tagCache[$type], $result); - $checksum[$type] += array_sum($result); + static::$tagCache = array_merge(static::$tagCache, $result); + $checksum += array_sum($result); } - } } return $checksum; diff --git a/core/lib/Drupal/Core/Cache/ApcuBackendFactory.php b/core/lib/Drupal/Core/Cache/ApcuBackendFactory.php index dd77ed1..0f5f362 100644 --- a/core/lib/Drupal/Core/Cache/ApcuBackendFactory.php +++ b/core/lib/Drupal/Core/Cache/ApcuBackendFactory.php @@ -42,29 +42,6 @@ public function get($bin) { } /** - * Deletes items with any of the specified tags. - * - * If the cache items are being deleted because they are no longer "fresh", - * you may consider using invalidateTags() instead. This allows callers to - * retrieve the invalid items by calling get() with $allow_invalid set to TRUE. - * In some cases an invalid item may be acceptable rather than having to - * rebuild the cache. - * - * @param array $tags - * Associative array of tags, in the same format that is passed to - * CacheBackendInterface::set(). - * - * @see \Drupal\Core\Cache\CacheBackendInterface::set() - * @see \Drupal\Core\Cache\CacheTagInvalidationInterface::invalidateTags() - * @see \Drupal\Core\Cache\CacheBackendInterface::delete() - * @see \Drupal\Core\Cache\CacheBackendInterface::deleteMultiple() - * @see \Drupal\Core\Cache\CacheBackendInterface::deleteAll() - */ - public function deleteTags(array $tags) { - // TODO: Implement deleteTags() method. - } - - /** * Marks cache items with any of the specified tags as invalid. * * @param array $tags @@ -72,7 +49,7 @@ public function deleteTags(array $tags) { * CacheBackendInterface::set(). * * @see \Drupal\Core\Cache\CacheBackendInterface::set() - * @see \Drupal\Core\Cache\CacheTagInvalidationInterface::deleteTags() + * @see \Drupal\Core\Cache\CacheTagInvalidationInterface::invalidateTags() * @see \Drupal\Core\Cache\CacheBackendInterface::invalidate() * @see \Drupal\Core\Cache\CacheBackendInterface::invalidateMultiple() * @see \Drupal\Core\Cache\CacheBackendInterface::invalidateAll() diff --git a/core/lib/Drupal/Core/Cache/BackendChain.php b/core/lib/Drupal/Core/Cache/BackendChain.php index 0cea142..d2aff4a 100644 --- a/core/lib/Drupal/Core/Cache/BackendChain.php +++ b/core/lib/Drupal/Core/Cache/BackendChain.php @@ -159,15 +159,6 @@ public function deleteMultiple(array $cids) { } /** - * Implements Drupal\Core\Cache\CacheBackendInterface::deleteTags(). - */ - public function deleteTags(array $tags) { - foreach ($this->backends as $backend) { - $backend->deleteTags($tags); - } - } - - /** * Implements Drupal\Core\Cache\CacheBackendInterface::deleteAll(). */ public function deleteAll() { diff --git a/core/lib/Drupal/Core/Cache/Cache.php b/core/lib/Drupal/Core/Cache/Cache.php index b8e6cdc..bdf7fb4 100644 --- a/core/lib/Drupal/Core/Cache/Cache.php +++ b/core/lib/Drupal/Core/Cache/Cache.php @@ -94,18 +94,6 @@ public static function buildTags($prefix, array $suffixes) { } /** - * Deletes items from all bins with any of the specified tags. - * - * @param string[] $tags - * The list of tags to delete cache items for. - */ - public static function deleteTags(array $tags) { - // @todo Move to service. - static::validateTags($tags); - \Drupal::service('cache_tags')->deleteTags($tags); - } - - /** * Marks cache items from all bins with any of the specified tags as invalid. * * @param string[] $tags diff --git a/core/lib/Drupal/Core/Cache/CacheBackendInterface.php b/core/lib/Drupal/Core/Cache/CacheBackendInterface.php index fd1ae87..b37ad95 100644 --- a/core/lib/Drupal/Core/Cache/CacheBackendInterface.php +++ b/core/lib/Drupal/Core/Cache/CacheBackendInterface.php @@ -136,7 +136,6 @@ public function setMultiple(array $items); * * @see \Drupal\Core\Cache\CacheBackendInterface::invalidate() * @see \Drupal\Core\Cache\CacheBackendInterface::deleteMultiple() - * @see \Drupal\Core\Cache\CacheBackendInterface::deleteTags() * @see \Drupal\Core\Cache\CacheBackendInterface::deleteAll() */ public function delete($cid); @@ -155,7 +154,6 @@ public function delete($cid); * * @see \Drupal\Core\Cache\CacheBackendInterface::invalidateMultiple() * @see \Drupal\Core\Cache\CacheBackendInterface::delete() - * @see \Drupal\Core\Cache\CacheBackendInterface::deleteTags() * @see \Drupal\Core\Cache\CacheBackendInterface::deleteAll() */ public function deleteMultiple(array $cids); @@ -166,7 +164,6 @@ public function deleteMultiple(array $cids); * @see \Drupal\Core\Cache\CacheBackendInterface::invalidateAll() * @see \Drupal\Core\Cache\CacheBackendInterface::delete() * @see \Drupal\Core\Cache\CacheBackendInterface::deleteMultiple() - * @see \Drupal\Core\Cache\CacheBackendInterface::deleteTags() */ public function deleteAll(); diff --git a/core/lib/Drupal/Core/Cache/CacheCollector.php b/core/lib/Drupal/Core/Cache/CacheCollector.php index d80da7d..a6d8ab5 100644 --- a/core/lib/Drupal/Core/Cache/CacheCollector.php +++ b/core/lib/Drupal/Core/Cache/CacheCollector.php @@ -280,7 +280,7 @@ public function reset() { public function clear() { $this->reset(); if ($this->tags) { - Cache::deleteTags($this->tags); + Cache::invalidateTags($this->tags); } else { $this->cache->delete($this->getCid()); diff --git a/core/lib/Drupal/Core/Cache/CacheTagHandler.php b/core/lib/Drupal/Core/Cache/CacheTagHandler.php index d439954..b5d7174 100644 --- a/core/lib/Drupal/Core/Cache/CacheTagHandler.php +++ b/core/lib/Drupal/Core/Cache/CacheTagHandler.php @@ -25,12 +25,6 @@ public function invalidateTags(array $tags) { } } - public function deleteTags(array $tags) { - foreach ($this->invalidators as $invalidator) { - $invalidator->deleteTags($tags); - } - } - public function addHandler(CacheTagInvalidationInterface $service) { $this->invalidators[] = $service; } diff --git a/core/lib/Drupal/Core/Cache/CacheTagHandlerInterface.php b/core/lib/Drupal/Core/Cache/CacheTagHandlerInterface.php index 288e04b..88cc26a 100644 --- a/core/lib/Drupal/Core/Cache/CacheTagHandlerInterface.php +++ b/core/lib/Drupal/Core/Cache/CacheTagHandlerInterface.php @@ -20,12 +20,4 @@ */ public function invalidateTags(array $tags); - /** - * Deletes cache items with any of the specified tags. - * - * @param string[] $tags - * The list of tags for which to delete cache items. - */ - public function deleteTags(array $tags); - } diff --git a/core/lib/Drupal/Core/Cache/CacheTagInvalidationInterface.php b/core/lib/Drupal/Core/Cache/CacheTagInvalidationInterface.php index 6efb15a..f5452c9 100644 --- a/core/lib/Drupal/Core/Cache/CacheTagInvalidationInterface.php +++ b/core/lib/Drupal/Core/Cache/CacheTagInvalidationInterface.php @@ -13,27 +13,6 @@ interface CacheTagInvalidationInterface { /** - * Deletes items with any of the specified tags. - * - * If the cache items are being deleted because they are no longer "fresh", - * you may consider using invalidateTags() instead. This allows callers to - * retrieve the invalid items by calling get() with $allow_invalid set to TRUE. - * In some cases an invalid item may be acceptable rather than having to - * rebuild the cache. - * - * @param array $tags - * Associative array of tags, in the same format that is passed to - * CacheBackendInterface::set(). - * - * @see \Drupal\Core\Cache\CacheBackendInterface::set() - * @see \Drupal\Core\Cache\CacheTagInvalidationInterface::invalidateTags() - * @see \Drupal\Core\Cache\CacheBackendInterface::delete() - * @see \Drupal\Core\Cache\CacheBackendInterface::deleteMultiple() - * @see \Drupal\Core\Cache\CacheBackendInterface::deleteAll() - */ - public function deleteTags(array $tags); - - /** * Marks cache items with any of the specified tags as invalid. * * @param array $tags @@ -41,7 +20,6 @@ public function deleteTags(array $tags); * CacheBackendInterface::set(). * * @see \Drupal\Core\Cache\CacheBackendInterface::set() - * @see \Drupal\Core\Cache\CacheTagInvalidationInterface::deleteTags() * @see \Drupal\Core\Cache\CacheBackendInterface::invalidate() * @see \Drupal\Core\Cache\CacheBackendInterface::invalidateMultiple() * @see \Drupal\Core\Cache\CacheBackendInterface::invalidateAll() diff --git a/core/lib/Drupal/Core/Cache/CacheTagInvalidationStorageInterface.php b/core/lib/Drupal/Core/Cache/CacheTagInvalidationStorageInterface.php index a200d44..88988e1 100644 --- a/core/lib/Drupal/Core/Cache/CacheTagInvalidationStorageInterface.php +++ b/core/lib/Drupal/Core/Cache/CacheTagInvalidationStorageInterface.php @@ -18,9 +18,8 @@ * @param array $tags * Array of cache tags. * - * @return int[] - * Array with cache tag invalidations and deletions for the set of passed in - * cache tags. + * @return int + * Cache tag invalidations checksum. */ public function checksumTags(array $tags); diff --git a/core/lib/Drupal/Core/Cache/ChainedFastBackend.php b/core/lib/Drupal/Core/Cache/ChainedFastBackend.php index f0b1986..2cabd96 100644 --- a/core/lib/Drupal/Core/Cache/ChainedFastBackend.php +++ b/core/lib/Drupal/Core/Cache/ChainedFastBackend.php @@ -204,14 +204,6 @@ public function deleteMultiple(array $cids) { /** * {@inheritdoc} */ - public function deleteTags(array $tags) { - $this->markAsOutdated(); - $this->consistentBackend->deleteTags($tags); - } - - /** - * {@inheritdoc} - */ public function deleteAll() { $this->markAsOutdated(); $this->consistentBackend->deleteAll(); diff --git a/core/lib/Drupal/Core/Cache/ChainedFastBackendFactory.php b/core/lib/Drupal/Core/Cache/ChainedFastBackendFactory.php index 90eef28..4f7f4cd 100644 --- a/core/lib/Drupal/Core/Cache/ChainedFastBackendFactory.php +++ b/core/lib/Drupal/Core/Cache/ChainedFastBackendFactory.php @@ -86,29 +86,6 @@ public function get($bin) { } /** - * Deletes items with any of the specified tags. - * - * If the cache items are being deleted because they are no longer "fresh", - * you may consider using invalidateTags() instead. This allows callers to - * retrieve the invalid items by calling get() with $allow_invalid set to TRUE. - * In some cases an invalid item may be acceptable rather than having to - * rebuild the cache. - * - * @param array $tags - * Associative array of tags, in the same format that is passed to - * CacheBackendInterface::set(). - * - * @see \Drupal\Core\Cache\CacheBackendInterface::set() - * @see \Drupal\Core\Cache\CacheTagInvalidationInterface::invalidateTags() - * @see \Drupal\Core\Cache\CacheBackendInterface::delete() - * @see \Drupal\Core\Cache\CacheBackendInterface::deleteMultiple() - * @see \Drupal\Core\Cache\CacheBackendInterface::deleteAll() - */ - public function deleteTags(array $tags) { - // TODO: Implement deleteTags() method. - } - - /** * Marks cache items with any of the specified tags as invalid. * * @param array $tags @@ -116,7 +93,6 @@ public function deleteTags(array $tags) { * CacheBackendInterface::set(). * * @see \Drupal\Core\Cache\CacheBackendInterface::set() - * @see \Drupal\Core\Cache\CacheTagInvalidationInterface::deleteTags() * @see \Drupal\Core\Cache\CacheBackendInterface::invalidate() * @see \Drupal\Core\Cache\CacheBackendInterface::invalidateMultiple() * @see \Drupal\Core\Cache\CacheBackendInterface::invalidateAll() diff --git a/core/lib/Drupal/Core/Cache/DatabaseBackend.php b/core/lib/Drupal/Core/Cache/DatabaseBackend.php index 56ebbb6..a379133 100644 --- a/core/lib/Drupal/Core/Cache/DatabaseBackend.php +++ b/core/lib/Drupal/Core/Cache/DatabaseBackend.php @@ -35,7 +35,7 @@ class DatabaseBackend implements CacheBackendInterface { protected $connection; /** - * Storage for cache tag invalidations and deletions. + * Storage for cache tag invalidations. * * @var \Drupal\Core\Cache\CacheTagInvalidationStorageInterface */ @@ -47,7 +47,7 @@ class DatabaseBackend implements CacheBackendInterface { * @param \Drupal\Core\Database\Connection $connection * The database connection. * @param \Drupal\Core\Cache\CacheTagInvalidationStorageInterface $cacheTagStorage - * The object that stores cache tag invalidations and deletions. + * The object that stores cache tag invalidations. * @param string $bin * The cache bin for which the object is created. */ @@ -86,7 +86,7 @@ public function getMultiple(&$cids, $allow_invalid = FALSE) { // ::select() is a much smaller proportion of the request. $result = array(); try { - $result = $this->connection->query('SELECT cid, data, created, expire, serialized, tags, checksum_invalidations, checksum_deletions FROM {' . $this->connection->escapeTable($this->bin) . '} WHERE cid IN (:cids)', array(':cids' => array_keys($cid_mapping))); + $result = $this->connection->query('SELECT cid, data, created, expire, serialized, tags, checksum_invalidations FROM {' . $this->connection->escapeTable($this->bin) . '} WHERE cid IN (:cids)', array(':cids' => array_keys($cid_mapping))); } catch (\Exception $e) { // Nothing to do. @@ -128,16 +128,11 @@ protected function prepareItem($cache, $allow_invalid) { $checksum = $this->cacheTagStorage->checksumTags($cache->tags); - // Check if deleteTags() has been called with any of the entry's tags. - if ($cache->checksum_deletions != $checksum['deletions']) { - return FALSE; - } - // Check expire time. $cache->valid = $cache->expire == Cache::PERMANENT || $cache->expire >= REQUEST_TIME; // Check if invalidateTags() has been called with any of the entry's tags. - if ($cache->checksum_invalidations != $checksum['invalidations']) { + if ($cache->checksum_invalidations != $checksum) { $cache->valid = FALSE; } @@ -193,8 +188,7 @@ protected function doSet($cid, $data, $expire, $tags) { 'created' => round(microtime(TRUE), 3), 'expire' => $expire, 'tags' => implode(' ', $tags), - 'checksum_invalidations' => $checksum['invalidations'], - 'checksum_deletions' => $checksum['deletions'], + 'checksum_invalidations' => $checksum, ); if (!is_string($data)) { $fields['data'] = serialize($data); @@ -226,7 +220,7 @@ public function setMultiple(array $items) { $query = $this->connection ->insert($this->bin) - ->fields(array('cid', 'data', 'expire', 'created', 'serialized', 'tags', 'checksum_invalidations', 'checksum_deletions')); + ->fields(array('cid', 'data', 'expire', 'created', 'serialized', 'tags', 'checksum_invalidations')); foreach ($items as $cid => $item) { $item += array( @@ -248,8 +242,7 @@ public function setMultiple(array $items) { 'expire' => $item['expire'], 'created' => round(microtime(TRUE), 3), 'tags' => implode(' ', $item['tags']), - 'checksum_invalidations' => $checksum['invalidations'], - 'checksum_deletions' => $checksum['deletions'], + 'checksum_invalidations' => $checksum, ); if (!is_string($item['data'])) { @@ -304,11 +297,6 @@ public function deleteMultiple(array $cids) { } /** - * Implements Drupal\Core\Cache\CacheBackendInterface::deleteTags(). - */ - public function deleteTags(array $tags) {} - - /** * Implements Drupal\Core\Cache\CacheBackendInterface::deleteAll(). */ public function deleteAll() { @@ -514,12 +502,6 @@ public function schemaDefinition() { 'not null' => TRUE, 'default' => 0, ), - 'checksum_deletions' => array( - 'description' => 'The tag deletion sum when this entry was saved.', - 'type' => 'int', - 'not null' => TRUE, - 'default' => 0, - ), ), 'indexes' => array( 'expire' => array('expire'), diff --git a/core/lib/Drupal/Core/Cache/DatabaseCacheTagStorage.php b/core/lib/Drupal/Core/Cache/DatabaseCacheTagStorage.php index 150d073..17a89f9 100644 --- a/core/lib/Drupal/Core/Cache/DatabaseCacheTagStorage.php +++ b/core/lib/Drupal/Core/Cache/DatabaseCacheTagStorage.php @@ -11,7 +11,7 @@ use Drupal\Core\Database\SchemaObjectExistsException; /** - * Storage for cache tag invalidations and deletions. + * Storage for cache tag invalidations. */ class DatabaseCacheTagStorage implements CacheTagInvalidationStorageInterface, CacheTagInvalidationInterface { @@ -23,22 +23,13 @@ class DatabaseCacheTagStorage implements CacheTagInvalidationStorageInterface, C protected $connection; /** - * Contains already loaded tags from the database. + * Contains already loaded cache invalidations from the database. * * @var array */ protected $tagCache = array(); /** - * A list of tags that have already been deleted in this requested. - * - * Used to prevent the deletion of the same cache tag multiple times. - * - * @var array - */ - protected $deletedTags = array(); - - /** * A list of tags that have already been invalidated in this requested. * * Used to prevent the invalidation of the same cache tag multiple times. @@ -89,47 +80,15 @@ public function invalidateTags(array $tags) { /** * {@inheritdoc} */ - public function deleteTags(array $tags) { - foreach ($tags as $tag) { - // Only delete tags once per request unless they are written again. - if (isset($this->deletedTags[$tag])) { - continue; - } - $this->deletedTags[$tag] = TRUE; - unset($this->tagCache[$tag]); - try { - $this->connection->merge('cachetags') - ->insertFields(array('deletions' => 1)) - ->expression('deletions', 'deletions + 1') - ->key('tag', $tag) - ->execute(); - } - catch (\Exception $e) { - // Create the cache table, which will be empty. This fixes cases during - // core install where a cache table is cleared before it is set - // with {cache_render} and {cache_data}. - if (!$this->ensureTableExists()) { - $this->catchException($e); - } - } - } - } - - /** - * {@inheritdoc} - */ public function checksumTags(array $tags) { - $checksum = array( - 'invalidations' => 0, - 'deletions' => 0, - ); + $invalidations = 0; $query_tags = array_diff($tags, array_keys($this->tagCache)); if ($query_tags) { $db_tags = array(); try { - $db_tags = $this->connection->query('SELECT tag, invalidations, deletions FROM {cachetags} WHERE tag IN (:tags)', array(':tags' => $query_tags)) - ->fetchAllAssoc('tag', \PDO::FETCH_ASSOC); + $db_tags = $this->connection->query('SELECT tag, invalidations FROM {cachetags} WHERE tag IN (:tags)', array(':tags' => $query_tags)) + ->fetchAllKeyed(); $this->tagCache += $db_tags; } catch (\Exception $e) { @@ -139,26 +98,23 @@ public function checksumTags(array $tags) { } } // Fill static cache with empty objects for tags not found in the database. - $this->tagCache += array_fill_keys(array_diff($query_tags, array_keys($db_tags)), $checksum); + $this->tagCache += array_fill_keys(array_diff($query_tags, array_keys($db_tags)), 0); } foreach ($tags as $tag) { - $checksum['invalidations'] += $this->tagCache[$tag]['invalidations']; - $checksum['deletions'] += $this->tagCache[$tag]['deletions']; + $invalidations += $this->tagCache[$tag]; } - return $checksum; + return $invalidations; } /** * {@inheritdoc} */ public function onCacheTagsWrite(array $tags) { - // Remove tags that were already deleted or invalidated during this request - // from the static caches so that another deletion or invalidation can - // occur. + // Remove tags that were already invalidated during this request/ from the + // static caches so that another deletion or invalidation can occur. foreach ($tags as $tag) { - unset($this->deletedTags[$tag]); unset($this->invalidatedTags[$tag]); } } @@ -168,7 +124,6 @@ public function onCacheTagsWrite(array $tags) { */ public function reset() { $this->tagCache = array(); - $this->deletedTags = array(); $this->invalidatedTags = array(); } @@ -215,12 +170,6 @@ public function schemaDefinition() { 'not null' => TRUE, 'default' => 0, ), - 'deletions' => array( - 'description' => 'Number incremented when the tag is deleted.', - 'type' => 'int', - 'not null' => TRUE, - 'default' => 0, - ), ), 'primary key' => array('tag'), ); diff --git a/core/lib/Drupal/Core/Cache/MemoryBackend.php b/core/lib/Drupal/Core/Cache/MemoryBackend.php index 23fddc5..b9d951b 100644 --- a/core/lib/Drupal/Core/Cache/MemoryBackend.php +++ b/core/lib/Drupal/Core/Cache/MemoryBackend.php @@ -144,17 +144,6 @@ public function deleteMultiple(array $cids) { } /** - * Implements Drupal\Core\Cache\CacheBackendInterface::deleteTags(). - */ - public function deleteTags(array $tags) { - foreach ($this->cache as $cid => $item) { - if (array_intersect($tags, $item->tags)) { - unset($this->cache[$cid]); - } - } - } - - /** * Implements Drupal\Core\Cache\CacheBackendInterface::deleteAll(). */ public function deleteAll() { diff --git a/core/lib/Drupal/Core/Cache/MemoryBackendFactory.php b/core/lib/Drupal/Core/Cache/MemoryBackendFactory.php index 6783720..af7f605 100644 --- a/core/lib/Drupal/Core/Cache/MemoryBackendFactory.php +++ b/core/lib/Drupal/Core/Cache/MemoryBackendFactory.php @@ -29,18 +29,9 @@ function get($bin) { /** * {@inheritdoc} */ - public function deleteTags(array $tags) { - foreach ($this->bins as $bin) { - $bin->deleteTags($tags); - } - } - - /** - * {@inheritdoc} - */ public function invalidateTags(array $tags) { foreach ($this->bins as $bin) { - $bin->deleteTags($tags); + $bin->invalidateTags($tags); } } } diff --git a/core/lib/Drupal/Core/Cache/NullBackend.php b/core/lib/Drupal/Core/Cache/NullBackend.php index fb898de..a97b3cc 100644 --- a/core/lib/Drupal/Core/Cache/NullBackend.php +++ b/core/lib/Drupal/Core/Cache/NullBackend.php @@ -70,11 +70,6 @@ public function deleteMultiple(array $cids) {} public function deleteAll() {} /** - * Implements Drupal\Core\Cache\CacheTagInvalidationInterface::deleteTags(). - */ - public function deleteTags(array $tags) {} - - /** * Implements Drupal\Core\Cache\CacheBackendInterface::invalidate(). */ public function invalidate($cid) {} diff --git a/core/lib/Drupal/Core/Cache/NullBackendFactory.php b/core/lib/Drupal/Core/Cache/NullBackendFactory.php index b1d9365..058a9e4 100644 --- a/core/lib/Drupal/Core/Cache/NullBackendFactory.php +++ b/core/lib/Drupal/Core/Cache/NullBackendFactory.php @@ -17,29 +17,6 @@ function get($bin) { } /** - * Deletes items with any of the specified tags. - * - * If the cache items are being deleted because they are no longer "fresh", - * you may consider using invalidateTags() instead. This allows callers to - * retrieve the invalid items by calling get() with $allow_invalid set to TRUE. - * In some cases an invalid item may be acceptable rather than having to - * rebuild the cache. - * - * @param array $tags - * Associative array of tags, in the same format that is passed to - * CacheBackendInterface::set(). - * - * @see \Drupal\Core\Cache\CacheBackendInterface::set() - * @see \Drupal\Core\Cache\CacheTagInvalidationInterface::invalidateTags() - * @see \Drupal\Core\Cache\CacheBackendInterface::delete() - * @see \Drupal\Core\Cache\CacheBackendInterface::deleteMultiple() - * @see \Drupal\Core\Cache\CacheBackendInterface::deleteAll() - */ - public function deleteTags(array $tags) { - // TODO: Implement deleteTags() method. - } - - /** * Marks cache items with any of the specified tags as invalid. * * @param array $tags @@ -47,7 +24,6 @@ public function deleteTags(array $tags) { * CacheBackendInterface::set(). * * @see \Drupal\Core\Cache\CacheBackendInterface::set() - * @see \Drupal\Core\Cache\CacheTagInvalidationInterface::deleteTags() * @see \Drupal\Core\Cache\CacheBackendInterface::invalidate() * @see \Drupal\Core\Cache\CacheBackendInterface::invalidateMultiple() * @see \Drupal\Core\Cache\CacheBackendInterface::invalidateAll() diff --git a/core/lib/Drupal/Core/Cache/NullCacheTagHandler.php b/core/lib/Drupal/Core/Cache/NullCacheTagHandler.php index 76b4c41..8fe1cc2 100644 --- a/core/lib/Drupal/Core/Cache/NullCacheTagHandler.php +++ b/core/lib/Drupal/Core/Cache/NullCacheTagHandler.php @@ -21,8 +21,6 @@ class NullCacheTagHandler implements CacheTagHandlerInterface { public function invalidateTags(array $tags) {} - public function deleteTags(array $tags) {} - public function addHandler(CacheTagInvalidationInterface $service) { $this->invalidators[] = $service; } diff --git a/core/lib/Drupal/Core/Cache/PhpBackend.php b/core/lib/Drupal/Core/Cache/PhpBackend.php index e188ffb..d4eea88 100644 --- a/core/lib/Drupal/Core/Cache/PhpBackend.php +++ b/core/lib/Drupal/Core/Cache/PhpBackend.php @@ -163,18 +163,6 @@ public function deleteMultiple(array $cids) { /** * {@inheritdoc} */ - public function deleteTags(array $tags) { - foreach ($this->storage()->listAll() as $cidhash) { - $item = $this->getByHash($cidhash); - if (is_object($item) && array_intersect($tags, $item->tags)) { - $this->delete($item->cid); - } - } - } - - /** - * {@inheritdoc} - */ public function deleteAll() { $this->storage()->deleteAll(); } diff --git a/core/lib/Drupal/Core/Cache/PhpBackendFactory.php b/core/lib/Drupal/Core/Cache/PhpBackendFactory.php index 872bf16..6102fa8 100644 --- a/core/lib/Drupal/Core/Cache/PhpBackendFactory.php +++ b/core/lib/Drupal/Core/Cache/PhpBackendFactory.php @@ -23,29 +23,6 @@ function get($bin) { } /** - * Deletes items with any of the specified tags. - * - * If the cache items are being deleted because they are no longer "fresh", - * you may consider using invalidateTags() instead. This allows callers to - * retrieve the invalid items by calling get() with $allow_invalid set to TRUE. - * In some cases an invalid item may be acceptable rather than having to - * rebuild the cache. - * - * @param array $tags - * Associative array of tags, in the same format that is passed to - * CacheBackendInterface::set(). - * - * @see \Drupal\Core\Cache\CacheBackendInterface::set() - * @see \Drupal\Core\Cache\CacheTagInvalidationInterface::invalidateTags() - * @see \Drupal\Core\Cache\CacheBackendInterface::delete() - * @see \Drupal\Core\Cache\CacheBackendInterface::deleteMultiple() - * @see \Drupal\Core\Cache\CacheBackendInterface::deleteAll() - */ - public function deleteTags(array $tags) { - // TODO: Implement deleteTags() method. - } - - /** * Marks cache items with any of the specified tags as invalid. * * @param array $tags @@ -53,7 +30,6 @@ public function deleteTags(array $tags) { * CacheBackendInterface::set(). * * @see \Drupal\Core\Cache\CacheBackendInterface::set() - * @see \Drupal\Core\Cache\CacheTagInvalidationInterface::deleteTags() * @see \Drupal\Core\Cache\CacheBackendInterface::invalidate() * @see \Drupal\Core\Cache\CacheBackendInterface::invalidateMultiple() * @see \Drupal\Core\Cache\CacheBackendInterface::invalidateAll() diff --git a/core/lib/Drupal/Core/Config/CachedStorage.php b/core/lib/Drupal/Core/Config/CachedStorage.php index b657f66..5023c35 100644 --- a/core/lib/Drupal/Core/Config/CachedStorage.php +++ b/core/lib/Drupal/Core/Config/CachedStorage.php @@ -131,7 +131,7 @@ public function write($name, array $data) { // While not all written data is read back, setting the cache instead of // just deleting it avoids cache rebuild stampedes. $this->cache->set($this->getCacheKey($name), $data); - Cache::deleteTags(array($this::FIND_BY_PREFIX_CACHE_TAG)); + Cache::invalidateTags(array($this::FIND_BY_PREFIX_CACHE_TAG)); $this->findByPrefixCache = array(); return TRUE; } @@ -146,7 +146,7 @@ public function delete($name) { // rebuilding the cache before the storage is gone. if ($this->storage->delete($name)) { $this->cache->delete($this->getCacheKey($name)); - Cache::deleteTags(array($this::FIND_BY_PREFIX_CACHE_TAG)); + Cache::invalidateTags(array($this::FIND_BY_PREFIX_CACHE_TAG)); $this->findByPrefixCache = array(); return TRUE; } @@ -162,7 +162,7 @@ public function rename($name, $new_name) { if ($this->storage->rename($name, $new_name)) { $this->cache->delete($this->getCacheKey($name)); $this->cache->delete($this->getCacheKey($new_name)); - Cache::deleteTags(array($this::FIND_BY_PREFIX_CACHE_TAG)); + Cache::invalidateTags(array($this::FIND_BY_PREFIX_CACHE_TAG)); $this->findByPrefixCache = array(); return TRUE; } diff --git a/core/lib/Drupal/Core/Entity/EntityManager.php b/core/lib/Drupal/Core/Entity/EntityManager.php index 7d7eded..cd9c9a7 100644 --- a/core/lib/Drupal/Core/Entity/EntityManager.php +++ b/core/lib/Drupal/Core/Entity/EntityManager.php @@ -671,7 +671,7 @@ public function clearCachedFieldDefinitions() { $this->fieldMapByFieldType = array(); $this->displayModeInfo = array(); $this->extraFields = array(); - Cache::deleteTags(array('entity_field_info')); + Cache::invalidateTags(array('entity_field_info')); // The typed data manager statically caches prototype objects with injected // definitions, clear those as well. $this->typedDataManager->clearCachedDefinitions(); @@ -682,7 +682,7 @@ public function clearCachedFieldDefinitions() { */ public function clearCachedBundles() { $this->bundleInfo = array(); - Cache::deleteTags(array('entity_bundles')); + Cache::invalidateTags(array('entity_bundles')); // Entity bundles are exposed as data types, clear that cache too. $this->typedDataManager->clearCachedDefinitions(); } diff --git a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php index 40a695e..bba66c0 100644 --- a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php +++ b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php @@ -574,7 +574,7 @@ public function resetCache(array $ids = NULL) { else { $this->entities = array(); if ($this->entityType->isPersistentlyCacheable()) { - $this->cacheBackend->deleteTags(array($this->entityTypeId . '_values')); + $this->cacheBackend->invalidateTags(array($this->entityTypeId . '_values')); } } } diff --git a/core/lib/Drupal/Core/EventSubscriber/MenuRouterRebuildSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/MenuRouterRebuildSubscriber.php index 41b5a87..57cc618 100644 --- a/core/lib/Drupal/Core/EventSubscriber/MenuRouterRebuildSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/MenuRouterRebuildSubscriber.php @@ -57,7 +57,7 @@ public function __construct(LockBackendInterface $lock, MenuLinkManagerInterface */ public function onRouterRebuild(Event $event) { $this->menuLinksRebuild(); - Cache::deleteTags(array('local_task')); + Cache::invalidateTags(array('local_task')); } /** diff --git a/core/lib/Drupal/Core/Extension/ThemeHandler.php b/core/lib/Drupal/Core/Extension/ThemeHandler.php index 8beb184..89ad503 100644 --- a/core/lib/Drupal/Core/Extension/ThemeHandler.php +++ b/core/lib/Drupal/Core/Extension/ThemeHandler.php @@ -621,7 +621,7 @@ protected function resetSystem() { // @todo It feels wrong to have the requirement to clear the local tasks // cache here. - Cache::deleteTags(array('local_task')); + Cache::invalidateTags(array('local_task')); $this->themeRegistryRebuild(); } diff --git a/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php b/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php index 5828d33..95928e4 100644 --- a/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php +++ b/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php @@ -161,7 +161,7 @@ public function clearCachedDefinitions() { if ($this->cacheBackend) { if ($this->cacheTags) { // Use the cache tags to clear the cache. - Cache::deleteTags($this->cacheTags); + Cache::invalidateTags($this->cacheTags); } else { $this->cacheBackend->delete($this->cacheKey); diff --git a/core/lib/Drupal/Core/Utility/Token.php b/core/lib/Drupal/Core/Utility/Token.php index 4cfc63f..e747565 100644 --- a/core/lib/Drupal/Core/Utility/Token.php +++ b/core/lib/Drupal/Core/Utility/Token.php @@ -346,7 +346,7 @@ public function setInfo(array $tokens) { */ public function resetInfo() { $this->tokenInfo = NULL; - $this->cache->deleteTags(array( + $this->cache->invalidateTags(array( static::TOKEN_INFO_CACHE_TAG => TRUE, )); } diff --git a/core/modules/book/src/BookManager.php b/core/modules/book/src/BookManager.php index e1f4282..3659f8d 100644 --- a/core/modules/book/src/BookManager.php +++ b/core/modules/book/src/BookManager.php @@ -433,7 +433,7 @@ public function deleteFromBook($nid) { } $this->updateOriginalParent($original); $this->books = NULL; - Cache::deleteTags(array('bid:' . $original['bid'])); + Cache::invalidateTags(array('bid:' . $original['bid'])); } /** @@ -763,7 +763,7 @@ public function saveBookLink(array $link, $new) { foreach ($affected_bids as $bid) { $cache_tags[] = 'bid:' . $bid; } - Cache::deleteTags($cache_tags); + Cache::invalidateTags($cache_tags); return $link; } diff --git a/core/modules/locale/locale.module b/core/modules/locale/locale.module index 82cff29..9e09a46 100644 --- a/core/modules/locale/locale.module +++ b/core/modules/locale/locale.module @@ -986,7 +986,7 @@ function _locale_refresh_translations($langcodes, $lids = array()) { } } // Clear locale cache. - Cache::deleteTags(array('locale')); + Cache::invalidateTags(array('locale')); } /** diff --git a/core/modules/locale/src/Tests/LocaleTranslationUiTest.php b/core/modules/locale/src/Tests/LocaleTranslationUiTest.php index 740bb0d..26c929e 100644 --- a/core/modules/locale/src/Tests/LocaleTranslationUiTest.php +++ b/core/modules/locale/src/Tests/LocaleTranslationUiTest.php @@ -136,7 +136,7 @@ public function testStringTranslation() { $this->assertRaw($translation_to_en, 'English translation properly saved.'); // Reset the tag cache on the tester side in order to pick up the call to - // Cache::deleteTags() on the tested side. + // Cache::invalidateTags() on the tested side. \Drupal::service('cache_tag_storage')->reset(); $this->assertTrue($name != $translation && t($name, array(), array('langcode' => $langcode)) == $translation, 't() works for non-English.'); diff --git a/core/modules/system/core.api.php b/core/modules/system/core.api.php index 96410cc..70b4e1b 100644 --- a/core/modules/system/core.api.php +++ b/core/modules/system/core.api.php @@ -496,7 +496,7 @@ * \Drupal::cache()->set($cid, $data, CacheBackendInterface::CACHE_PERMANENT, $tags); * * // Delete or invalidate all cache items with certain tags. - * \Drupal\Core\Cache\Cache::deleteTags(array('node:1')); + * \Drupal\Core\Cache\Cache::invalidateTags(array('node:1')); * \Drupal\Core\Cache\Cache::invalidateTags(array('user:1')); * @endcode * diff --git a/core/modules/system/src/Tests/Cache/DatabaseBackendTagTest.php b/core/modules/system/src/Tests/Cache/DatabaseBackendTagTest.php index e2b9d37..24cef4d 100644 --- a/core/modules/system/src/Tests/Cache/DatabaseBackendTagTest.php +++ b/core/modules/system/src/Tests/Cache/DatabaseBackendTagTest.php @@ -62,28 +62,4 @@ public function testTagInvalidations() { $this->assertEqual($invalidations_after, $invalidations_before + 1, 'Only one addition cache tag invalidation has occurred after invalidating a tag used in multiple bins.'); } - public function testTagDeletions() { - // Create cache entry in multiple bins. - $tags = array('test_tag:1', 'test_tag:2', 'test_tag:3'); - $bins = array('data', 'bootstrap', 'render'); - foreach ($bins as $bin) { - $bin = \Drupal::cache($bin); - $bin->set('test', 'value', Cache::PERMANENT, $tags); - $this->assertTrue($bin->get('test'), 'Cache item was set in bin.'); - } - - $deletions_before = intval(db_select('cachetags')->fields('cachetags', array('deletions'))->condition('tag', 'test_tag:2')->execute()->fetchField()); - Cache::deleteTags(array('test_tag:2')); - - // Test that cache entry has been deleted in multiple bins. - foreach ($bins as $bin) { - $bin = \Drupal::cache($bin); - $this->assertFalse($bin->get('test'), 'Tag invalidation affected item in bin.'); - } - - // Test that only one tag deletion has occurred. - $deletions_after = intval(db_select('cachetags')->fields('cachetags', array('deletions'))->condition('tag', 'test_tag:2')->execute()->fetchField()); - $this->assertEqual($deletions_after, $deletions_before + 1, 'Only one addition cache tag deletion has occurred after deleting a tag used in multiple bins.'); - } - } diff --git a/core/modules/system/src/Tests/Cache/GenericCacheBackendUnitTestBase.php b/core/modules/system/src/Tests/Cache/GenericCacheBackendUnitTestBase.php index 5ce1ab5..754bab9 100644 --- a/core/modules/system/src/Tests/Cache/GenericCacheBackendUnitTestBase.php +++ b/core/modules/system/src/Tests/Cache/GenericCacheBackendUnitTestBase.php @@ -474,63 +474,6 @@ public function testDeleteMultiple() { } /** - * Tests Drupal\Core\Cache\CacheBackendInterface::deleteTags(). - */ - function testDeleteTags() { - $backend = $this->getCacheBackend(); - - // Create two cache entries with the same tag and tag value. - $backend->set('test_cid_invalidate1', $this->defaultValue, Cache::PERMANENT, array('test_tag:2')); - $backend->set('test_cid_invalidate2', $this->defaultValue, Cache::PERMANENT, array('test_tag:2')); - $this->assertTrue($backend->get('test_cid_invalidate1') && $backend->get('test_cid_invalidate2'), 'Two cache items were created.'); - - // Delete test_tag of value 1. This should delete both entries. - Cache::deleteTags(array('test_tag:2')); - $this->assertFalse($backend->get('test_cid_invalidate1') || $backend->get('test_cid_invalidate2'), 'Two cache items invalidated after deleting a cache tag.'); - $this->assertFalse($backend->get('test_cid_invalidate1', TRUE) || $backend->get('test_cid_invalidate2', TRUE), 'Two cache items deleted after deleting a cache tag.'); - - // Create two cache entries with the same tag and an array tag value. - $backend->set('test_cid_invalidate1', $this->defaultValue, Cache::PERMANENT, array('test_tag:1')); - $backend->set('test_cid_invalidate2', $this->defaultValue, Cache::PERMANENT, array('test_tag:1')); - $this->assertTrue($backend->get('test_cid_invalidate1') && $backend->get('test_cid_invalidate2'), 'Two cache items were created.'); - - // Delete test_tag of value 1. This should delete both entries. - Cache::deleteTags(array('test_tag:1')); - $this->assertFalse($backend->get('test_cid_invalidate1') || $backend->get('test_cid_invalidate2'), 'Two cache items invalidated after deleted a cache tag.'); - $this->assertFalse($backend->get('test_cid_invalidate1', TRUE) || $backend->get('test_cid_invalidate2', TRUE), 'Two cache items deleted after deleting a cache tag.'); - - // Create three cache entries with a mix of tags and tag values. - $backend->set('test_cid_invalidate1', $this->defaultValue, Cache::PERMANENT, array('test_tag:1')); - $backend->set('test_cid_invalidate2', $this->defaultValue, Cache::PERMANENT, array('test_tag:2')); - $backend->set('test_cid_invalidate3', $this->defaultValue, Cache::PERMANENT, array('test_tag_foo:3')); - $this->assertTrue($backend->get('test_cid_invalidate1') && $backend->get('test_cid_invalidate2') && $backend->get('test_cid_invalidate3'), 'Three cached items were created.'); - Cache::deleteTags(array('test_tag_foo:3')); - $this->assertTrue($backend->get('test_cid_invalidate1') && $backend->get('test_cid_invalidate2'), 'Cached items not matching the tag were not deleted.'); - $this->assertFalse($backend->get('test_cid_invalidated3', TRUE), 'Cache item matching the tag was deleted.'); - - // Create cache entry in multiple bins. Two cache entries - // (test_cid_invalidate1 and test_cid_invalidate2) still exist from previous - // tests. - $tags = array('test_tag:1', 'test_tag:2', 'test_tag:3'); - $bins = array('path', 'bootstrap', 'page'); - foreach ($bins as $bin) { - $this->getCacheBackend($bin)->set('test', $this->defaultValue, Cache::PERMANENT, $tags); - $this->assertTrue($this->getCacheBackend($bin)->get('test'), 'Cache item was set in bin.'); - } - - Cache::deleteTags(array('test_tag:2')); - - // Test that cache entry has been deleted in multple bins. - foreach ($bins as $bin) { - $this->assertFalse($this->getCacheBackend($bin)->get('test', TRUE), 'Tag deletion affected item in bin.'); - } - // Test that the cache entry with a matching tag has been invalidated. - $this->assertFalse($this->getCacheBackend($bin)->get('test_cid_invalidate2', TRUE), 'Cache items matching tag were deleted.'); - // Test that the cache entry with without a matching tag still exists. - $this->assertTrue($this->getCacheBackend($bin)->get('test_cid_invalidate1'), 'Cache items not matching tag were not invalidated.'); - } - - /** * Test Drupal\Core\Cache\CacheBackendInterface::deleteAll(). */ public function testDeleteAll() { diff --git a/core/modules/toolbar/src/Tests/ToolbarAdminMenuTest.php b/core/modules/toolbar/src/Tests/ToolbarAdminMenuTest.php index d0c0685..7b612ed 100644 --- a/core/modules/toolbar/src/Tests/ToolbarAdminMenuTest.php +++ b/core/modules/toolbar/src/Tests/ToolbarAdminMenuTest.php @@ -267,7 +267,7 @@ function testCacheClearByCacheTag() { // Log in admin_user and clear the caches for this user using a tag. $this->drupalLogin($this->admin_user); - Cache::deleteTags(array('user:' . $admin_user_id)); + Cache::invalidateTags(array('user:' . $admin_user_id)); // Assert that no toolbar cache exists for admin_user against the // language "en". diff --git a/core/modules/views/src/ViewsData.php b/core/modules/views/src/ViewsData.php index 796e94b..c90c69e 100644 --- a/core/modules/views/src/ViewsData.php +++ b/core/modules/views/src/ViewsData.php @@ -322,6 +322,6 @@ public function clear() { $this->storage = array(); $this->allStorage = array(); $this->fullyLoaded = FALSE; - Cache::deleteTags(array('views_data')); + Cache::invalidateTags(array('views_data')); } } diff --git a/core/modules/views/tests/src/Unit/ViewsDataTest.php b/core/modules/views/tests/src/Unit/ViewsDataTest.php index 4bd856d..18424c9 100644 --- a/core/modules/views/tests/src/Unit/ViewsDataTest.php +++ b/core/modules/views/tests/src/Unit/ViewsDataTest.php @@ -259,7 +259,7 @@ public function testFullAndTableGetCache() { ->method('set') ->with("views_data:$random_table_name:en", array()); $this->cacheTagHandler->expects($this->once()) - ->method('deleteTags') + ->method('invalidateTags') ->with(['views_data']); $this->cacheBackend->expects($this->at(4)) ->method('get') diff --git a/core/modules/views/views.module b/core/modules/views/views.module index e6b56d1..65bc1a0 100644 --- a/core/modules/views/views.module +++ b/core/modules/views/views.module @@ -472,7 +472,7 @@ function views_field_config_create(FieldConfigInterface $field) { * Implements hook_ENTITY_TYPE_update() for 'field_config'. */ function views_field_config_update(FieldConfigInterface $field) { - Cache::deleteTags(array('extension' => 'views')); + Cache::invalidateTags(array('extension' => 'views')); \Drupal::cache('render')->deleteAll(); } @@ -480,7 +480,7 @@ function views_field_config_update(FieldConfigInterface $field) { * Implements hook_ENTITY_TYPE_delete() for 'field_config'. */ function views_field_config_delete(FieldConfigInterface $field) { - Cache::deleteTags(array('extension' => 'views')); + Cache::invalidateTags(array('extension' => 'views')); \Drupal::cache('render')->deleteAll(); } @@ -489,7 +489,7 @@ function views_field_config_delete(FieldConfigInterface $field) { */ function views_invalidate_cache() { // Clear Views' info cache entries. - Cache::deleteTags(array('extension' => 'views')); + Cache::invalidateTags(array('extension' => 'views')); // Set the menu as needed to be rebuilt. \Drupal::service('router.builder_indicator')->setRebuildNeeded(); diff --git a/core/tests/Drupal/Tests/Core/Cache/BackendChainImplementationUnitTest.php b/core/tests/Drupal/Tests/Core/Cache/BackendChainImplementationUnitTest.php index f977695..6ab09c4 100644 --- a/core/tests/Drupal/Tests/Core/Cache/BackendChainImplementationUnitTest.php +++ b/core/tests/Drupal/Tests/Core/Cache/BackendChainImplementationUnitTest.php @@ -229,7 +229,7 @@ public function testDeleteTagsPropagation() { 'Two cache items were created in all backends.'); // Invalidate test_tag of value 1. This should invalidate both entries. - $this->chain->deleteTags(array('test_tag:2')); + $this->chain->invalidateTags(array('test_tag:2')); $this->assertSame(FALSE, $this->firstBackend->get('test_cid_clear1') && $this->firstBackend->get('test_cid_clear2') && $this->secondBackend->get('test_cid_clear1') @@ -250,7 +250,7 @@ public function testDeleteTagsPropagation() { 'Two cache items were created in all backends.'); // Invalidate test_tag of value 1. This should invalidate both entries. - $this->chain->deleteTags(array('test_tag:1')); + $this->chain->invalidateTags(array('test_tag:1')); $this->assertSame(FALSE, $this->firstBackend->get('test_cid_clear1') && $this->firstBackend->get('test_cid_clear2') && $this->secondBackend->get('test_cid_clear1') @@ -274,7 +274,7 @@ public function testDeleteTagsPropagation() { && $this->thirdBackend->get('test_cid_clear3'), 'Three cached items were created in all backends.'); - $this->chain->deleteTags(array('test_tag_foo:3')); + $this->chain->invalidateTags(array('test_tag_foo:3')); $this->assertNotSame(FALSE, $this->firstBackend->get('test_cid_clear1') && $this->firstBackend->get('test_cid_clear2') && $this->secondBackend->get('test_cid_clear1') diff --git a/core/tests/Drupal/Tests/Core/Cache/CacheCollectorTest.php b/core/tests/Drupal/Tests/Core/Cache/CacheCollectorTest.php index 2b53e0a..462a743 100644 --- a/core/tests/Drupal/Tests/Core/Cache/CacheCollectorTest.php +++ b/core/tests/Drupal/Tests/Core/Cache/CacheCollectorTest.php @@ -385,7 +385,7 @@ public function testUpdateCacheClear() { ->method('delete') ->with($this->cid); $this->cacheTagHandler->expects($this->never()) - ->method('deleteTags'); + ->method('invalidateTags'); $this->collector->clear(); $this->assertEquals($value, $this->collector->get($key)); $this->assertEquals(2, $this->collector->getCacheMisses()); @@ -412,7 +412,7 @@ public function testUpdateCacheClearTags() { $this->cacheBackend->expects($this->never()) ->method('delete'); $this->cacheTagHandler->expects($this->once()) - ->method('deleteTags') + ->method('invalidateTags') ->with($tags); $this->collector->clear(); $this->assertEquals($value, $this->collector->get($key)); diff --git a/core/tests/Drupal/Tests/Core/Cache/CacheTest.php b/core/tests/Drupal/Tests/Core/Cache/CacheTest.php index a425572..a01fbf5 100644 --- a/core/tests/Drupal/Tests/Core/Cache/CacheTest.php +++ b/core/tests/Drupal/Tests/Core/Cache/CacheTest.php @@ -118,16 +118,6 @@ public function testBuildTags($prefix, array $suffixes, array $expected) { } /** - * @covers ::deleteTags - * - * @expectedException \LogicException - * @expectedExceptionMessage Cache tags must be strings, array given. - */ - public function testDeleteTags() { - Cache::deleteTags(['node' => [2, 3, 5, 8, 13]]); - } - - /** * @covers ::invalidateTags * * @expectedException \LogicException diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityManagerTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityManagerTest.php index cf7a2f4..4951648 100644 --- a/core/tests/Drupal/Tests/Core/Entity/EntityManagerTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/EntityManagerTest.php @@ -202,13 +202,13 @@ protected function setUpEntityManager($definitions = array()) { public function testClearCachedDefinitions() { $this->setUpEntityManager(); $this->cacheTagHandler->expects($this->at(0)) - ->method('deleteTags') + ->method('invalidateTags') ->with(array('entity_types')); $this->cacheTagHandler->expects($this->at(1)) - ->method('deleteTags') + ->method('invalidateTags') ->with(array('entity_bundles')); $this->cacheTagHandler->expects($this->at(2)) - ->method('deleteTags') + ->method('invalidateTags') ->with(array('entity_field_info')); $this->entityManager->clearCachedDefinitions(); @@ -780,7 +780,7 @@ protected function setUpEntityWithFieldDefinition($custom_invoke_all = FALSE, $f public function testClearCachedFieldDefinitions() { $this->setUpEntityManager(); $this->cacheTagHandler->expects($this->once()) - ->method('deleteTags') + ->method('invalidateTags') ->with(array('entity_field_info')); $this->typedDataManager->expects($this->once()) ->method('clearCachedDefinitions'); @@ -796,7 +796,7 @@ public function testClearCachedFieldDefinitions() { public function testClearCachedBundles() { $this->setUpEntityManager(); $this->cacheTagHandler->expects($this->once()) - ->method('deleteTags') + ->method('invalidateTags') ->with(array('entity_bundles')); $this->entityManager->clearCachedBundles(); @@ -882,13 +882,13 @@ public function testGetAllBundleInfo() { ->method('set') ->with("entity_bundle_info:en"); $this->cacheTagHandler->expects($this->at(0)) - ->method('deleteTags') + ->method('invalidateTags') ->with(array('entity_types')); $this->cacheTagHandler->expects($this->at(1)) - ->method('deleteTags') + ->method('invalidateTags') ->with(array('entity_bundles')); $this->cacheTagHandler->expects($this->at(2)) - ->method('deleteTags') + ->method('invalidateTags') ->with(array('entity_field_info')); $this->cacheBackend->expects($this->at(4)) ->method('get') diff --git a/core/tests/Drupal/Tests/Core/Plugin/DefaultPluginManagerTest.php b/core/tests/Drupal/Tests/Core/Plugin/DefaultPluginManagerTest.php index db6bda3..585a194 100644 --- a/core/tests/Drupal/Tests/Core/Plugin/DefaultPluginManagerTest.php +++ b/core/tests/Drupal/Tests/Core/Plugin/DefaultPluginManagerTest.php @@ -194,7 +194,7 @@ public function testCacheClearWithTags() { $cache_tag_handler = $this->getMock('Drupal\Core\Cache\CacheTagHandlerInterface'); $cache_tag_handler ->expects($this->once()) - ->method('deleteTags') + ->method('invalidateTags') ->with(array('tag')); $cache_backend ->expects($this->never())