diff --git a/core/lib/Drupal/Core/Cache/CacheTagInterface.php b/core/lib/Drupal/Core/Cache/CacheTagInterface.php index fd09b70..773f101 100644 --- a/core/lib/Drupal/Core/Cache/CacheTagInterface.php +++ b/core/lib/Drupal/Core/Cache/CacheTagInterface.php @@ -34,8 +34,25 @@ public function deleteTags(array $tags); */ public function invalidateTags(array $tags); + /** + * @param array $tags + * Associative array of tags. + * @return array + * Array with two items (invalidations, deletions) providing sum of all + * invalidations/deletions over all provided tags. + */ public function checksumTags(array $tags); + /** + * Prepares cache item before it is returned from cache backend interface. + * + * $item->deleted should be set to TRUE if item was deleted via tags and + * $item->valid should be set to FALSE if item was invalidated. + */ public function prepareGet(&$item); + /** + * Clears cache tag service internal caches. + */ + public function clearCache(); } diff --git a/core/lib/Drupal/Core/Cache/DatabaseTag.php b/core/lib/Drupal/Core/Cache/DatabaseTag.php index 10f6a9e..4d05ef9 100644 --- a/core/lib/Drupal/Core/Cache/DatabaseTag.php +++ b/core/lib/Drupal/Core/Cache/DatabaseTag.php @@ -144,4 +144,10 @@ protected function catchException(\Exception $e, $table_name = NULL) { } } + /** + * {@inheritdoc}. + */ + public function clearCache() { + $this->tagCache = array(); + } } diff --git a/core/lib/Drupal/Core/Cache/MemoryBackend.php b/core/lib/Drupal/Core/Cache/MemoryBackend.php index 261712b..9d6596a 100644 --- a/core/lib/Drupal/Core/Cache/MemoryBackend.php +++ b/core/lib/Drupal/Core/Cache/MemoryBackend.php @@ -93,7 +93,7 @@ protected function prepareItem($cache, $allow_invalid) { // Check expire time. $cache->valid = $time_valid = $cache->expire == Cache::PERMANENT || $cache->expire >= REQUEST_TIME; - $this->cacheTag->prepareGet($item); + $this->cacheTag->prepareGet($cache); if ($cache->deleted) { $this->delete($cache->cid); return FALSE; diff --git a/core/lib/Drupal/Core/Cache/MemoryTag.php b/core/lib/Drupal/Core/Cache/MemoryTag.php index 616732c..b82248b 100644 --- a/core/lib/Drupal/Core/Cache/MemoryTag.php +++ b/core/lib/Drupal/Core/Cache/MemoryTag.php @@ -94,4 +94,11 @@ public function prepareGet(&$item) { $item->valid = FALSE; } } + + /** + * {@inheritdoc}. + */ + public function clearCache() { + // Nothing to be done here. + } } diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleTranslationUiTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleTranslationUiTest.php index c3fc74e..04064ce 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleTranslationUiTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleTranslationUiTest.php @@ -142,7 +142,7 @@ function testStringTranslation() { // Reset the tag cache on the tester side in order to pick up the call to // Cache::deleteTags() on the tested side. - drupal_static_reset('Drupal\Core\Cache\CacheBackendInterface::tagCache'); + $this->container->get('cache.tag.database')->clearCache(); $this->assertTrue($name != $translation && t($name, array(), array('langcode' => $langcode)) == $translation, 't() works for non-English.'); // Refresh the locale() cache to get fresh data from t() below. We are in diff --git a/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php index 92b161f..1dcb454 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php @@ -190,6 +190,7 @@ public function containerBuild(ContainerBuilder $container) { $container->register('lock', 'Drupal\Core\Lock\NullLockBackend'); $this->settingsSet('cache', array('default' => 'cache.backend.memory')); + $this->settingsSet('cache_tag_service', 'cache.tag.memory'); $container ->register('config.storage', 'Drupal\Core\Config\FileStorage') diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php index 3917ffa..334a4a0 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php @@ -775,6 +775,7 @@ protected function setUp() { // Execute the non-interactive installer. require_once DRUPAL_ROOT . '/core/includes/install.core.inc'; $this->settingsSet('cache', array('default' => 'cache.backend.memory')); + $this->settingsSet('cache_tag_service', 'cache.tag.memory'); $parameters = $this->installParameters(); install_drupal($parameters); @@ -1004,7 +1005,7 @@ protected function resetAll() { */ protected function refreshVariables() { // Clear the tag cache. - drupal_static_reset('Drupal\Core\Cache\CacheBackendInterface::tagCache'); + $this->container->get('cache.tag.database')->clearCache(); \Drupal::service('config.factory')->reset(); \Drupal::state()->resetCache();