diff -u b/core/lib/Drupal/Core/Config/CachedStorage.php b/core/lib/Drupal/Core/Config/CachedStorage.php --- b/core/lib/Drupal/Core/Config/CachedStorage.php +++ b/core/lib/Drupal/Core/Config/CachedStorage.php @@ -90,14 +90,14 @@ * {@inheritdoc} */ public function readMultiple(array $names) { - $remaining_names = $names; $list = array(); - $cached_list = $this->cache->getMultiple($remaining_names); + // The names array is passed by reference and will only contain the names of + // config object not found after the method call. + // @see Drupal\Core\Cache\CacheBackendInterface::getMultiple() + $cached_list = $this->cache->getMultiple($names); - // The cache backend removed names that were successfully loaded from the - // cache. - if (!empty($remaining_names)) { - $list = $this->storage->readMultiple($remaining_names); + if (!empty($names)) { + $list = $this->storage->readMultiple($names); // Cache configuration objects that were loaded from the storage. foreach ($list as $name => $data) { $this->cache->set($name, $data, CacheBackendInterface::CACHE_PERMANENT); @@ -120,7 +120,7 @@ // While not all written data is read back, setting the cache instead of // just deleting it avoids cache rebuild stampedes. $this->cache->set($name, $data, CacheBackendInterface::CACHE_PERMANENT); - $this->cache->deleteTags(array('findByPrefix' => TRUE)); + $this->cache->deleteTags(array($this::FIND_BY_PREFIX_CACHE_TAG => TRUE)); $this->findByPrefixCache = array(); return TRUE; } @@ -135,7 +135,7 @@ // rebuilding the cache before the storage is gone. if ($this->storage->delete($name)) { $this->cache->delete($name); - $this->cache->deleteTags(array('findByPrefix' => TRUE)); + $this->cache->deleteTags(array($this::FIND_BY_PREFIX_CACHE_TAG => TRUE)); $this->findByPrefixCache = array(); return TRUE; } @@ -151,7 +151,7 @@ if ($this->storage->rename($name, $new_name)) { $this->cache->delete($name); $this->cache->delete($new_name); - $this->cache->deleteTags(array('findByPrefix' => TRUE)); + $this->cache->deleteTags(array($this::FIND_BY_PREFIX_CACHE_TAG => TRUE)); $this->findByPrefixCache = array(); return TRUE; } @@ -208,7 +208,12 @@ } else { $this->findByPrefixCache[$prefix] = $this->storage->listAll($prefix); - $this->cache->set('find:' . $prefix, $this->findByPrefixCache[$prefix], CacheBackendInterface::CACHE_PERMANENT, array('findByPrefix' => TRUE)); + $this->cache->set( + 'find:' . $prefix, + $this->findByPrefixCache[$prefix], + CacheBackendInterface::CACHE_PERMANENT, + array($this::FIND_BY_PREFIX_CACHE_TAG => TRUE) + ); } } return $this->findByPrefixCache[$prefix]; diff -u b/core/lib/Drupal/Core/Config/StorageCacheInterface.php b/core/lib/Drupal/Core/Config/StorageCacheInterface.php --- b/core/lib/Drupal/Core/Config/StorageCacheInterface.php +++ b/core/lib/Drupal/Core/Config/StorageCacheInterface.php @@ -13,6 +13,14 @@ interface StorageCacheInterface { /** + * Cache tag. + * + * Used by Drupal\Core\Config\CachedStorage::findByPrefix so that cached items + * can be cleared during writes, deletes and renames. + */ + const FIND_BY_PREFIX_CACHE_TAG = 'configFindByPrefix'; + + /** * Reset the static cache of the listAll() cache. */ public function resetListCache(); diff -u b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php --- b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php @@ -934,6 +934,8 @@ global $conf; cache('bootstrap')->delete('variables'); $conf = variable_initialize(); + // Clear the tag cache. + drupal_static_reset('Drupal\Core\Cache\CacheBackendInterface::tagCache'); drupal_container()->get('config.factory')->reset(); } @@ -950,8 +952,6 @@ global $conf; cache('bootstrap')->delete('variables'); $conf = variable_initialize(); - // Clear the tag cache. - drupal_static_reset('Drupal\Core\Cache\CacheBackendInterface::tagCache'); drupal_container()->get('config.factory')->reset(); }