.../Core/Asset/LibraryDiscoveryCollector.php | 2 +- core/lib/Drupal/Core/Cache/ApcuBackend.php | 37 +++-------------- core/lib/Drupal/Core/Cache/Cache.php | 39 +++++++++++++----- core/lib/Drupal/Core/Cache/CacheCollector.php | 3 +- core/lib/Drupal/Core/Cache/DatabaseBackend.php | 3 ++ core/lib/Drupal/Core/Cache/MemoryBackend.php | 1 + core/lib/Drupal/Core/Cache/PhpBackend.php | 1 + core/lib/Drupal/Core/Config/CachedStorage.php | 8 ++-- core/lib/Drupal/Core/Entity/EntityViewBuilder.php | 4 +- .../MenuRouterRebuildSubscriber.php | 2 +- core/lib/Drupal/Core/Extension/ThemeHandler.php | 2 +- core/lib/Drupal/Core/Menu/MenuTreeStorage.php | 2 +- .../Drupal/Core/Plugin/DefaultPluginManager.php | 1 + core/lib/Drupal/Core/Theme/Registry.php | 6 +-- .../src/Tests/AggregatorRenderingTest.php | 8 ++-- core/modules/block/src/Tests/BlockTest.php | 29 +++++++------ core/modules/breakpoint/src/BreakpointManager.php | 4 +- .../src/Tests/EditorFileReferenceFilterTest.php | 13 +++--- .../src/Tests/EntityReferenceFormatterTest.php | 15 ++++--- core/modules/filter/filter.module | 2 +- core/modules/filter/src/FilterProcessResult.php | 3 +- core/modules/filter/src/Tests/FilterAPITest.php | 10 ++--- .../src/Plugin/Filter/FilterTestCacheTags.php | 4 +- .../src/Plugin/Block/SystemBrandingBlock.php | 6 +-- .../system/src/Tests/Bootstrap/PageCacheTest.php | 10 ++--- .../src/Tests/Cache/DatabaseBackendTagTest.php | 8 ++-- .../Cache/GenericCacheBackendUnitTestBase.php | 48 +++++++++++----------- .../system/src/Tests/Theme/RegistryTest.php | 4 +- .../src/Controller/SystemTestController.php | 2 +- .../text/src/Tests/Formatter/TextFormatterTest.php | 6 +-- .../toolbar/src/Tests/ToolbarAdminMenuTest.php | 2 +- .../src/Plugin/views/cache/CachePluginBase.php | 4 +- .../Core/Asset/LibraryDiscoveryCollectorTest.php | 2 +- .../Drupal/Tests/Core/Cache/CacheCollectorTest.php | 2 +- .../Tests/Core/Menu/LocalTaskIntegrationTest.php | 2 +- .../Tests/Core/Menu/LocalTaskManagerTest.php | 4 +- .../Tests/Core/Plugin/DefaultPluginManagerTest.php | 4 +- 37 files changed, 151 insertions(+), 152 deletions(-) diff --git a/core/lib/Drupal/Core/Asset/LibraryDiscoveryCollector.php b/core/lib/Drupal/Core/Asset/LibraryDiscoveryCollector.php index e174a17..dfac4fa 100644 --- a/core/lib/Drupal/Core/Asset/LibraryDiscoveryCollector.php +++ b/core/lib/Drupal/Core/Asset/LibraryDiscoveryCollector.php @@ -57,7 +57,7 @@ class LibraryDiscoveryCollector extends CacheCollector { * The library discovery parser. */ public function __construct(CacheBackendInterface $cache, LockBackendInterface $lock, LibraryDiscoveryParser $discovery_parser) { - parent::__construct($this->cacheKey, $cache, $lock, array($this->cacheKey => array(TRUE))); + parent::__construct($this->cacheKey, $cache, $lock, array($this->cacheKey)); $this->discoveryParser = $discovery_parser; } diff --git a/core/lib/Drupal/Core/Cache/ApcuBackend.php b/core/lib/Drupal/Core/Cache/ApcuBackend.php index 0ec166f..f787401 100644 --- a/core/lib/Drupal/Core/Cache/ApcuBackend.php +++ b/core/lib/Drupal/Core/Cache/ApcuBackend.php @@ -189,11 +189,12 @@ protected function prepareItem($cache, $allow_invalid) { * {@inheritdoc} */ public function set($cid, $data, $expire = CacheBackendInterface::CACHE_PERMANENT, array $tags = array()) { + Cache::validateTags($tags); $cache = new \stdClass(); $cache->cid = $cid; $cache->created = round(microtime(TRUE), 3); $cache->expire = $expire; - $cache->tags = implode(' ', $this->flattenTags($tags)); + $cache->tags = implode(' ', $tags); $checksum = $this->checksumTags($tags); $cache->checksum_invalidations = $checksum['invalidations']; $cache->checksum_deletions = $checksum['deletions']; @@ -285,7 +286,7 @@ public function invalidateAll() { * {@inheritdoc} */ public function deleteTags(array $tags) { - foreach ($this->flattenTags($tags) as $tag) { + foreach ($tags as $tag) { apc_inc($this->deletionsTagsPrefix . $tag, 1, $success); if (!$success) { apc_store($this->deletionsTagsPrefix . $tag, 1); @@ -297,7 +298,7 @@ public function deleteTags(array $tags) { * {@inheritdoc} */ public function invalidateTags(array $tags) { - foreach ($this->flattenTags($tags) as $tag) { + foreach ($tags as $tag) { apc_inc($this->invalidationsTagsPrefix . $tag, 1, $success); if (!$success) { apc_store($this->invalidationsTagsPrefix . $tag, 1); @@ -306,34 +307,6 @@ public function invalidateTags(array $tags) { } /** - * Flattens a tags array into a numeric array suitable for string storage. - * - * @param array $tags - * Associative array of tags to flatten. - * - * @return array - * Indexed array of flattened tag identifiers. - */ - protected function flattenTags(array $tags) { - if (isset($tags[0])) { - return $tags; - } - - $flat_tags = array(); - foreach ($tags as $namespace => $values) { - if (is_array($values)) { - foreach ($values as $value) { - $flat_tags[] = "$namespace:$value"; - } - } - else { - $flat_tags[] = "$namespace:$values"; - } - } - return $flat_tags; - } - - /** * Returns the sum total of validations for a given set of tags. * * @param array $tags @@ -346,7 +319,7 @@ protected function checksumTags(array $tags) { $checksum = array('invalidations' => 0, 'deletions' => 0); $query_tags = array('invalidations' => array(), 'deletions' => array()); - foreach ($this->flattenTags($tags) as $tag) { + foreach ($tags as $tag) { foreach (array('deletions', 'invalidations') as $type) { if (isset(static::$tagCache[$type][$tag])) { $checksum[$type] += static::$tagCache[$type][$tag]; diff --git a/core/lib/Drupal/Core/Cache/Cache.php b/core/lib/Drupal/Core/Cache/Cache.php index 895d8ec..68d316c 100644 --- a/core/lib/Drupal/Core/Cache/Cache.php +++ b/core/lib/Drupal/Core/Cache/Cache.php @@ -22,7 +22,7 @@ class Cache { const PERMANENT = CacheBackendInterface::CACHE_PERMANENT; /** - * Merges sets of cache tags. + * Merges arrays of cache tags. * * The cache tags array is returned in a format that is valid for * \Drupal\Core\Cache\CacheBackendInterface::set(). @@ -40,18 +40,35 @@ class Cache { */ public static function mergeTags() { $cache_tag_arrays = func_get_args(); - $result = []; + $cache_tags = []; foreach ($cache_tag_arrays as $tags) { - foreach ($tags as $value) { - if (!is_string($value)) { - throw new \LogicException('Cache tags must be strings, ' . gettype($value) . ' given.'); - } + static::validateTags($tags); + $cache_tags = array_merge($cache_tags, $tags); + } + $cache_tags = array_unique($cache_tags); + sort($cache_tags); + return $cache_tags; + } + + /** + * Validates an array of cache tags. + * + * Can be called before using cache tags in operations, to ensure validity. + * + * @param array $tags + * An array of cache tags. + * + * @throws \LogicException + */ + public static function validateTags(array $tags) { + if (empty($tags)) { + return; + } + foreach ($tags as $value) { + if (!is_string($value)) { + throw new \LogicException('Cache tags must be strings, ' . gettype($value) . ' given.'); } - $result = array_merge($result, $tags); } - $result = array_unique($result); - sort($result); - return $result; } /** @@ -68,6 +85,7 @@ public static function mergeTags() { * The list of tags to delete cache items for. */ public static function deleteTags(array $tags) { + static::validateTags($tags); foreach (static::getBins() as $cache_backend) { $cache_backend->deleteTags($tags); } @@ -87,6 +105,7 @@ public static function deleteTags(array $tags) { * The list of tags to invalidate cache items for. */ public static function invalidateTags(array $tags) { + static::validateTags($tags); foreach (static::getBins() as $cache_backend) { $cache_backend->invalidateTags($tags); } diff --git a/core/lib/Drupal/Core/Cache/CacheCollector.php b/core/lib/Drupal/Core/Cache/CacheCollector.php index b90327e..d1689af 100644 --- a/core/lib/Drupal/Core/Cache/CacheCollector.php +++ b/core/lib/Drupal/Core/Cache/CacheCollector.php @@ -114,7 +114,8 @@ * @param array $tags * (optional) The tags to specify for the cache item. */ - public function __construct($cid, CacheBackendInterface $cache, LockBackendInterface $lock, $tags = array()) { + public function __construct($cid, CacheBackendInterface $cache, LockBackendInterface $lock, array $tags = array()) { + Cache::validateTags($tags); $this->cid = $cid; $this->cache = $cache; $this->tags = $tags; diff --git a/core/lib/Drupal/Core/Cache/DatabaseBackend.php b/core/lib/Drupal/Core/Cache/DatabaseBackend.php index 250a8a9..b243967 100644 --- a/core/lib/Drupal/Core/Cache/DatabaseBackend.php +++ b/core/lib/Drupal/Core/Cache/DatabaseBackend.php @@ -147,6 +147,7 @@ protected function prepareItem($cache, $allow_invalid) { * Implements Drupal\Core\Cache\CacheBackendInterface::set(). */ public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = array()) { + Cache::validateTags($tags); $try_again = FALSE; try { // The bin might not yet exist. @@ -233,6 +234,8 @@ public function setMultiple(array $items) { 'tags' => array(), ); + Cache::validateTags($item['tags']); + // Remove tags that were already deleted or invalidated during this // request from the static caches so that another deletion or // invalidation can occur. diff --git a/core/lib/Drupal/Core/Cache/MemoryBackend.php b/core/lib/Drupal/Core/Cache/MemoryBackend.php index 34f2853..a8814ac 100644 --- a/core/lib/Drupal/Core/Cache/MemoryBackend.php +++ b/core/lib/Drupal/Core/Cache/MemoryBackend.php @@ -107,6 +107,7 @@ protected function prepareItem($cache, $allow_invalid) { * Implements Drupal\Core\Cache\CacheBackendInterface::set(). */ public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = array()) { + Cache::validateTags($tags); $this->cache[$cid] = (object) array( 'cid' => $cid, 'data' => serialize($data), diff --git a/core/lib/Drupal/Core/Cache/PhpBackend.php b/core/lib/Drupal/Core/Cache/PhpBackend.php index 3ac9934..26117f3 100644 --- a/core/lib/Drupal/Core/Cache/PhpBackend.php +++ b/core/lib/Drupal/Core/Cache/PhpBackend.php @@ -140,6 +140,7 @@ public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = array 'expire' => $expire, 'tags' => $tags, ); + Cache::validateTags($item['tags']); $this->writeItem($this->normalizeCid($cid), $item); } diff --git a/core/lib/Drupal/Core/Config/CachedStorage.php b/core/lib/Drupal/Core/Config/CachedStorage.php index 0b089ca..b657f66 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 => TRUE)); + Cache::deleteTags(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 => TRUE)); + Cache::deleteTags(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 => TRUE)); + Cache::deleteTags(array($this::FIND_BY_PREFIX_CACHE_TAG)); $this->findByPrefixCache = array(); return TRUE; } @@ -224,7 +224,7 @@ protected function findByPrefix($prefix) { 'find:' . $cache_key, $this->findByPrefixCache[$cache_key], Cache::PERMANENT, - array($this::FIND_BY_PREFIX_CACHE_TAG => TRUE) + array($this::FIND_BY_PREFIX_CACHE_TAG) ); } } diff --git a/core/lib/Drupal/Core/Entity/EntityViewBuilder.php b/core/lib/Drupal/Core/Entity/EntityViewBuilder.php index 3bfe032..e989182 100644 --- a/core/lib/Drupal/Core/Entity/EntityViewBuilder.php +++ b/core/lib/Drupal/Core/Entity/EntityViewBuilder.php @@ -352,9 +352,9 @@ public function getCacheTag() { public function resetCache(array $entities = NULL) { if (isset($entities)) { // Always invalidate the ENTITY_TYPE_list tag. - $tags = array($this->entityTypeId . '_list' => TRUE); + $tags = array($this->entityTypeId . '_list'); foreach ($entities as $entity) { - $tags = NestedArray::mergeDeep($tags, $entity->getCacheTag()); + $tags = Cache::mergeTags($tags, $entity->getCacheTag()); } Cache::invalidateTags($tags); } diff --git a/core/lib/Drupal/Core/EventSubscriber/MenuRouterRebuildSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/MenuRouterRebuildSubscriber.php index 4b0b41f..41b5a87 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' => 1)); + Cache::deleteTags(array('local_task')); } /** diff --git a/core/lib/Drupal/Core/Extension/ThemeHandler.php b/core/lib/Drupal/Core/Extension/ThemeHandler.php index a4a086a..0425df5 100644 --- a/core/lib/Drupal/Core/Extension/ThemeHandler.php +++ b/core/lib/Drupal/Core/Extension/ThemeHandler.php @@ -643,7 +643,7 @@ protected function resetSystem() { // @todo It feels wrong to have the requirement to clear the local tasks // cache here. - Cache::deleteTags(array('local_task' => 1)); + Cache::deleteTags(array('local_task')); $this->themeRegistryRebuild(); } diff --git a/core/lib/Drupal/Core/Menu/MenuTreeStorage.php b/core/lib/Drupal/Core/Menu/MenuTreeStorage.php index 422ec5c..b7e525f 100644 --- a/core/lib/Drupal/Core/Menu/MenuTreeStorage.php +++ b/core/lib/Drupal/Core/Menu/MenuTreeStorage.php @@ -845,7 +845,7 @@ public function loadTreeData($menu_name, MenuTreeParameters $parameters) { $data['tree'] = $this->doBuildTreeData($links, $parameters->activeTrail, $parameters->minDepth); $data['definitions'] = array(); $data['route_names'] = $this->collectRoutesAndDefinitions($data['tree'], $data['definitions']); - $this->menuCacheBackend->set($tree_cid, $data, Cache::PERMANENT, array('menu' => $menu_name)); + $this->menuCacheBackend->set($tree_cid, $data, Cache::PERMANENT, array('menu:' . $menu_name)); // The definitions were already added to $this->definitions in // $this->doBuildTreeData() unset($data['definitions']); diff --git a/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php b/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php index a2d4cf2..5828d33 100644 --- a/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php +++ b/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php @@ -125,6 +125,7 @@ public function __construct($subdir, \Traversable $namespaces, ModuleHandlerInte * definitions should be cleared along with other, related cache entries. */ public function setCacheBackend(CacheBackendInterface $cache_backend, $cache_key, array $cache_tags = array()) { + Cache::validateTags($cache_tags); $this->cacheBackend = $cache_backend; $this->cacheKey = $cache_key; $this->cacheTags = $cache_tags; diff --git a/core/lib/Drupal/Core/Theme/Registry.php b/core/lib/Drupal/Core/Theme/Registry.php index 59f9761..da3122c 100644 --- a/core/lib/Drupal/Core/Theme/Registry.php +++ b/core/lib/Drupal/Core/Theme/Registry.php @@ -235,7 +235,7 @@ public function get() { public function getRuntime() { $this->init($this->themeName); if (!isset($this->runtimeRegistry)) { - $this->runtimeRegistry = new ThemeRegistry('theme_registry:runtime:' . $this->theme->getName(), $this->cache, $this->lock, array('theme_registry' => TRUE), $this->moduleHandler->isLoaded()); + $this->runtimeRegistry = new ThemeRegistry('theme_registry:runtime:' . $this->theme->getName(), $this->cache, $this->lock, array('theme_registry'), $this->moduleHandler->isLoaded()); } return $this->runtimeRegistry; } @@ -244,7 +244,7 @@ public function getRuntime() { * Persists the theme registry in the cache backend. */ protected function setCache() { - $this->cache->set('theme_registry:' . $this->theme->getName(), $this->registry, Cache::PERMANENT, array('theme_registry' => TRUE)); + $this->cache->set('theme_registry:' . $this->theme->getName(), $this->registry, Cache::PERMANENT, array('theme_registry')); } /** @@ -318,7 +318,7 @@ protected function build() { } // Only cache this registry if all modules are loaded. if ($this->moduleHandler->isLoaded()) { - $this->cache->set("theme_registry:build:modules", $cache, Cache::PERMANENT, array('theme_registry' => TRUE)); + $this->cache->set("theme_registry:build:modules", $cache, Cache::PERMANENT, array('theme_registry')); } } diff --git a/core/modules/aggregator/src/Tests/AggregatorRenderingTest.php b/core/modules/aggregator/src/Tests/AggregatorRenderingTest.php index d967d1b..22515a3 100644 --- a/core/modules/aggregator/src/Tests/AggregatorRenderingTest.php +++ b/core/modules/aggregator/src/Tests/AggregatorRenderingTest.php @@ -67,8 +67,8 @@ public function testBlockLinks() { $this->assertFalse(empty($correct_titles), 'Aggregator feed page is available and has the correct title.'); $cache_tags = explode(' ', $this->drupalGetHeader('X-Drupal-Cache-Tags')); $this->assertTrue(in_array('aggregator_feed:' . $feed->id(), $cache_tags)); - $this->assertTrue(in_array('aggregator_feed_view:1', $cache_tags)); - $this->assertTrue(in_array('aggregator_item_view:1', $cache_tags)); + $this->assertTrue(in_array('aggregator_feed_view', $cache_tags)); + $this->assertTrue(in_array('aggregator_item_view', $cache_tags)); // Set the number of news items to 0 to test that the block does not show // up. @@ -119,8 +119,8 @@ public function testFeedPage() { $this->assertTrue(!empty($elements), 'Individual source page contains a pager.'); $cache_tags = explode(' ', $this->drupalGetHeader('X-Drupal-Cache-Tags')); $this->assertTrue(in_array('aggregator_feed:' . $feed->id(), $cache_tags)); - $this->assertTrue(in_array('aggregator_feed_view:1', $cache_tags)); - $this->assertTrue(in_array('aggregator_item_view:1', $cache_tags)); + $this->assertTrue(in_array('aggregator_feed_view', $cache_tags)); + $this->assertTrue(in_array('aggregator_item_view', $cache_tags)); } } diff --git a/core/modules/block/src/Tests/BlockTest.php b/core/modules/block/src/Tests/BlockTest.php index 6240fcd..c560236 100644 --- a/core/modules/block/src/Tests/BlockTest.php +++ b/core/modules/block/src/Tests/BlockTest.php @@ -294,21 +294,23 @@ public function testBlockCacheTags() { $cache_entry = \Drupal::cache('render')->get($cid); $expected_cache_tags = array( 'theme:stark', - 'theme_global_settings:1', - 'block_view:1', + 'theme_global_settings', + 'block_view', 'block:powered', 'block_plugin:system_powered_by_block', - 'rendered:1', + 'rendered', ); + sort($expected_cache_tags); $this->assertIdentical($cache_entry->tags, $expected_cache_tags); $cache_entry = \Drupal::cache('render')->get('entity_view:block:powered:en:stark'); $expected_cache_tags = array( - 'block_view:1', + 'block_view', 'block:powered', 'theme:stark', 'block_plugin:system_powered_by_block', - 'rendered:1', + 'rendered', ); + sort($expected_cache_tags); $this->assertIdentical($cache_entry->tags, $expected_cache_tags); // The "Powered by Drupal" block is modified; verify a cache miss. @@ -334,30 +336,33 @@ public function testBlockCacheTags() { $cache_entry = \Drupal::cache('render')->get($cid); $expected_cache_tags = array( 'theme:stark', - 'theme_global_settings:1', - 'block_view:1', + 'theme_global_settings', + 'block_view', 'block:powered-2', 'block:powered', 'block_plugin:system_powered_by_block', - 'rendered:1', + 'rendered', ); + sort($expected_cache_tags); $this->assertEqual($cache_entry->tags, $expected_cache_tags); $expected_cache_tags = array( - 'block_view:1', + 'block_view', 'block:powered', 'theme:stark', 'block_plugin:system_powered_by_block', - 'rendered:1', + 'rendered', ); + sort($expected_cache_tags); $cache_entry = \Drupal::cache('render')->get('entity_view:block:powered:en:stark'); $this->assertIdentical($cache_entry->tags, $expected_cache_tags); $expected_cache_tags = array( - 'block_view:1', + 'block_view', 'block:powered-2', 'theme:stark', 'block_plugin:system_powered_by_block', - 'rendered:1', + 'rendered', ); + sort($expected_cache_tags); $cache_entry = \Drupal::cache('render')->get('entity_view:block:powered-2:en:stark'); $this->assertIdentical($cache_entry->tags, $expected_cache_tags); diff --git a/core/modules/breakpoint/src/BreakpointManager.php b/core/modules/breakpoint/src/BreakpointManager.php index 289170b..3187912 100644 --- a/core/modules/breakpoint/src/BreakpointManager.php +++ b/core/modules/breakpoint/src/BreakpointManager.php @@ -176,7 +176,7 @@ public function getBreakpointsByGroup($group) { } } uasort($breakpoints, array('Drupal\Component\Utility\SortArray', 'sortByWeightElement')); - $this->cacheBackend->set($this->cacheKey . ':' . $group, $breakpoints, Cache::PERMANENT, array('breakpoints' => TRUE)); + $this->cacheBackend->set($this->cacheKey . ':' . $group, $breakpoints, Cache::PERMANENT, array('breakpoints')); $this->breakpointsByGroup[$group] = $breakpoints; } } @@ -205,7 +205,7 @@ public function getGroups() { $groups[$plugin_definition['group']] = $plugin_definition['group']; } } - $this->cacheBackend->set($this->cacheKey . '::groups', $groups, Cache::PERMANENT, array('breakpoints' => TRUE)); + $this->cacheBackend->set($this->cacheKey . '::groups', $groups, Cache::PERMANENT, array('breakpoints')); } // Get the labels. This is not cacheable due to translation. $group_labels = array(); diff --git a/core/modules/editor/src/Tests/EditorFileReferenceFilterTest.php b/core/modules/editor/src/Tests/EditorFileReferenceFilterTest.php index e03066e..7fa1813 100644 --- a/core/modules/editor/src/Tests/EditorFileReferenceFilterTest.php +++ b/core/modules/editor/src/Tests/EditorFileReferenceFilterTest.php @@ -7,6 +7,7 @@ namespace Drupal\editor\Tests; +use Drupal\Core\Cache\Cache; use Drupal\simpletest\KernelTestBase; use Drupal\filter\FilterBag; @@ -58,12 +59,14 @@ function testEditorFileReferenceFilter() { $image->save(); $id = $image->id(); $uuid = $image->uuid(); + $cache_tag = ['file:' . $id]; file_put_contents('public://alpaca.jpg', $this->randomMachineName()); $image_2 = entity_create('file', array('uri' => 'public://alpaca.jpg')); $image_2->save(); $id_2 = $image_2->id(); $uuid_2 = $image_2->uuid(); + $cache_tag_2 = ['file:' . $id_2]; $this->pass('No data-editor-file-uuid attribute.'); $input = ''; @@ -74,19 +77,19 @@ function testEditorFileReferenceFilter() { $input = ''; $output = $test($input); $this->assertIdentical($input, $output->getProcessedText()); - $this->assertEqual(array('file' => array($id)), $output->getCacheTags()); + $this->assertEqual($cache_tag, $output->getCacheTags()); $this->pass('One data-editor-file-uuid attribute with odd capitalization.'); $input = ''; $output = $test($input); $this->assertIdentical($input, $output->getProcessedText()); - $this->assertEqual(array('file' => array($id)), $output->getCacheTags()); + $this->assertEqual($cache_tag, $output->getCacheTags()); $this->pass('One data-editor-file-uuid attribute on a non-image tag.'); $input = '