diff --git a/core/lib/Drupal/Core/Config/CachedStorage.php b/core/lib/Drupal/Core/Config/CachedStorage.php index beb8c09..2067b40 100644 --- a/core/lib/Drupal/Core/Config/CachedStorage.php +++ b/core/lib/Drupal/Core/Config/CachedStorage.php @@ -68,22 +68,14 @@ public function exists($name) { */ public function read($name) { if ($cache = $this->cache->get($name)) { - // The cache backend supports primitive data types, but only an array - // represents valid config object data. - if (is_array($cache->data)) { - return $cache->data; - } + // The cache contains either the cached configuration data or FALSE + // if the configuration file does not exist. + return $cache->data; } - // Read from the storage on a cache miss and cache the data, if any. + // Read from the storage on a cache miss and cache the data. Also cache + // information about missing configuration objects. $data = $this->storage->read($name); - if ($data !== FALSE) { - $this->cache->set($name, $data, CacheBackendInterface::CACHE_PERMANENT); - } - // If the cache contained bogus data and there is no data in the storage, - // wipe the cache entry. - elseif ($cache) { - $this->cache->delete($name); - } + $this->cache->set($name, $data, CacheBackendInterface::CACHE_PERMANENT); return $data; } @@ -99,9 +91,10 @@ public function readMultiple(array $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); + // Cache configuration objects that were loaded from the storage, cache + // missing configuration objects as an explicit FALSE. + foreach ($names as $name) { + $this->cache->set($name, isset($list[$name]) ? $list[$name] : FALSE, CacheBackendInterface::CACHE_PERMANENT); } } @@ -110,7 +103,9 @@ public function readMultiple(array $names) { $list[$name] = $cache->data; } - return $list; + // Ensure that only existing configuration objects are returned, filter out + // cached information about missing objects. + return array_filter($list); } /** diff --git a/core/lib/Drupal/Core/Config/ConfigFactory.php b/core/lib/Drupal/Core/Config/ConfigFactory.php index 742e628..2487069 100644 --- a/core/lib/Drupal/Core/Config/ConfigFactory.php +++ b/core/lib/Drupal/Core/Config/ConfigFactory.php @@ -417,9 +417,8 @@ public function getLanguage() { if ($this->enforcedLanguage) { return $this->enforcedLanguage; } - // Only return a language if there is a language manager and this is - // a multilingual site. - if ($this->languageManager && $this->languageManager->isMultilingual()) { + // Only return a language if there is a language manager. + if ($this->languageManager) { return $this->languageManager->getCurrentLanguage(); } }