diff --git a/core/lib/Drupal/Core/Cache/Cache.php b/core/lib/Drupal/Core/Cache/Cache.php index c9acef8..82bb6a0 100644 --- a/core/lib/Drupal/Core/Cache/Cache.php +++ b/core/lib/Drupal/Core/Cache/Cache.php @@ -32,7 +32,7 @@ class Cache { * @return string[] * The merged array of cache contexts. */ - public static function mergeContexts(array $a = array(), array $b = array()) { + public static function mergeContexts(array $a = [], array $b = []) { $cache_contexts = array_unique(array_merge($a, $b)); \Drupal::service('cache_contexts_manager')->validateTokens($cache_contexts); sort($cache_contexts); @@ -58,7 +58,7 @@ public static function mergeContexts(array $a = array(), array $b = array()) { * @return string[] * The merged array of cache tags. */ - public static function mergeTags(array $a = array(), array $b = array()) { + public static function mergeTags(array $a = [], array $b = []) { $cache_tags = array_unique(array_merge($a, $b)); static::validateTags($cache_tags); sort($cache_tags); diff --git a/core/modules/system/src/Tests/Entity/EntityCacheTagsTestBase.php b/core/modules/system/src/Tests/Entity/EntityCacheTagsTestBase.php index 2d7b339..326103d 100644 --- a/core/modules/system/src/Tests/Entity/EntityCacheTagsTestBase.php +++ b/core/modules/system/src/Tests/Entity/EntityCacheTagsTestBase.php @@ -1,7 +1,3 @@ - if (count($access_cache_contexts)) { - $contexts = Cache::mergeContexts($entity_cache_contexts, $this->getAdditionalCacheContextsForEntity($this->referencingEntity)); - $contexts = Cache::mergeContexts($contexts, $access_cache_contexts); - $redirected_cid = $this->createCacheId($cache_keys, $contexts); getAdditionalCacheContextsForEntity($this->referencingEntity); $redirected_cid = NULL; if (count($access_cache_contexts) || count($additional_cache_contexts)) { - $cache_contexts = Cache::mergeContexts($entity_cache_contexts, $additional_cache_contexts, $access_cache_contexts); + $cache_contexts = Cache::mergeContexts($entity_cache_contexts, $additional_cache_contexts); + $cache_contexts = Cache::mergeContexts($cache_contexts, $access_cache_contexts); $redirected_cid = $this->createCacheId($cache_keys, $cache_contexts); $context_metadata = \Drupal::service('cache_contexts_manager')->convertTokensToKeys($cache_contexts); $referencing_entity_cache_tags = Cache::mergeTags($referencing_entity_cache_tags, $context_metadata->getCacheTags()); diff --git a/core/modules/tracker/src/Tests/TrackerTest.php b/core/modules/tracker/src/Tests/TrackerTest.php index 2536cec..4a3ac34 100644 --- a/core/modules/tracker/src/Tests/TrackerTest.php +++ b/core/modules/tracker/src/Tests/TrackerTest.php @@ -79,7 +79,9 @@ function testTrackerAll() { // Assert cache contexts, specifically the pager and node access contexts. $this->assertCacheContexts(['languages:language_interface', 'theme', 'url.query_args.pagers:0', 'user.node_grants:view', 'user.permissions']); // Assert cache tags for the visible node and node list cache tag. - $this->assertCacheTags(Cache::mergeTags($published->getCacheTags(), $published->getOwner()->getCacheTags(), ['node_list', 'rendered'])); + $expectedTags = Cache::mergeTags($published->getCacheTags(), $published->getOwner()->getCacheTags()); + $expectedTags = Cache::mergeTags($expectedTags, ['node_list', 'rendered']); + $this->assertCacheTags($expectedTags); // Delete a node and ensure it no longer appears on the tracker. $published->delete(); @@ -150,7 +152,7 @@ function testTrackerUser() { $expected_tags = Cache::mergeTags($expected_tags, ['node_list', 'rendered']); $this->assertCacheTags($expected_tags); - $this->assertCacheContexts(['languages:language_interface', 'theme', 'url.query_args.pagers:0', 'user']); + $this->assertCacheContexts(['languages:language_interface', 'theme', 'url.query_args.pagers:0', 'user', 'user.node_grants:view']); $this->assertLink($my_published->label()); $this->assertNoLink($unpublished->label());