diff --git a/core/lib/Drupal/Core/Cache/Cache.php b/core/lib/Drupal/Core/Cache/Cache.php
index d149592..ba99651 100644
--- a/core/lib/Drupal/Core/Cache/Cache.php
+++ b/core/lib/Drupal/Core/Cache/Cache.php
@@ -24,19 +24,16 @@ class Cache {
   /**
    * Merges arrays of cache contexts and removes duplicates.
    *
-   * @param string[] …
-   *   Arrays of cache contexts to merge.
+   * @param array $a
+   *    Cache context array to merge.
+   * @param array $b
+   *    Cache context array to merge.
    *
    * @return string[]
    *   The merged array of cache contexts.
    */
-  public static function mergeContexts() {
-    $cache_context_arrays = func_get_args();
-    $cache_contexts = [];
-    foreach ($cache_context_arrays as $contexts) {
-      $cache_contexts = array_merge($cache_contexts, $contexts);
-    }
-    $cache_contexts = array_unique($cache_contexts);
+  public static function mergeContexts($a = array(), $b = array()) {
+    $cache_contexts = array_unique(array_merge($a, $b));
     \Drupal::service('cache_contexts_manager')->validateTokens($cache_contexts);
     sort($cache_contexts);
     return $cache_contexts;
@@ -53,19 +50,16 @@ public static function mergeContexts() {
    * allows items to be invalidated based on all tags attached to the content
    * they're constituted from.
    *
-   * @param string[] …
-   *   Arrays of cache tags to merge.
+   * @param array $a
+   *    Cache tag array to merge.
+   * @param array $b
+   *    Cache tag array to merge.
    *
    * @return string[]
    *   The merged array of cache tags.
    */
-  public static function mergeTags() {
-    $cache_tag_arrays = func_get_args();
-    $cache_tags = [];
-    foreach ($cache_tag_arrays as $tags) {
-      $cache_tags = array_merge($cache_tags, $tags);
-    }
-    $cache_tags = array_unique($cache_tags);
+  public static function mergeTags($a = array(), $b = array()) {
+    $cache_tags = array_unique(array_merge($a, $b));
     static::validateTags($cache_tags);
     sort($cache_tags);
     return $cache_tags;
@@ -76,29 +70,25 @@ public static function mergeTags() {
    *
    * Ensures infinite max-age (Cache::PERMANENT) is taken into account.
    *
-   * @param int …
-   *   Max-age values.
+   * @param int $a
+   *    Max age value to find.
+   * @param int $b
+   *    Max age value to find.
    *
    * @return int
    *   The minimum max-age value.
    */
-  public static function mergeMaxAges() {
-    $max_ages = func_get_args();
-
-    // Filter out all max-age values set to cache permanently.
-    if (in_array(Cache::PERMANENT, $max_ages)) {
-      $max_ages = array_filter($max_ages, function ($max_age) {
-        return $max_age !== Cache::PERMANENT;
-      });
-
-      // If nothing is left, then all max-age values were set to cache
-      // permanently, and then that is the result.
-      if (empty($max_ages)) {
-        return Cache::PERMANENT;
-      }
+  public static function mergeMaxAges($a = Cache::PERMANENT, $b = Cache::PERMANENT) {
+    // If one of the values is Cache::PERMANENT, return the other value.
+    if ($a == Cache::PERMANENT){
+      return $b;
+    }
+    if ($b == Cache::PERMANENT){
+      return $a;
     }
 
-    return min($max_ages);
+    // If none or the values are Cache::PERMANENT, return the minimum value.
+    return min($a, $b);
   }
 
   /**
diff --git a/core/lib/Drupal/Core/Entity/EntityViewBuilder.php b/core/lib/Drupal/Core/Entity/EntityViewBuilder.php
index e9fdb13..be11df7 100644
--- a/core/lib/Drupal/Core/Entity/EntityViewBuilder.php
+++ b/core/lib/Drupal/Core/Entity/EntityViewBuilder.php
@@ -368,7 +368,8 @@ public function resetCache(array $entities = NULL) {
     if (isset($entities)) {
       $tags = [];
       foreach ($entities as $entity) {
-        $tags = Cache::mergeTags($tags, $entity->getCacheTags(), $entity->getEntityType()->getListCacheTags());
+        $tags = Cache::mergeTags($tags, $entity->getCacheTags());
+        $tags = Cache::mergeTags($tags, $entity->getEntityType()->getListCacheTags());
       }
       Cache::invalidateTags($tags);
     }
diff --git a/core/modules/block/src/BlockViewBuilder.php b/core/modules/block/src/BlockViewBuilder.php
index 216dfa8..6bfd71f 100644
--- a/core/modules/block/src/BlockViewBuilder.php
+++ b/core/modules/block/src/BlockViewBuilder.php
@@ -46,6 +46,15 @@ public function viewMultiple(array $entities = array(), $view_mode = 'full', $la
       $derivative_id = $plugin->getDerivativeId();
       $configuration = $plugin->getConfiguration();
 
+      $cache_tags = Cache::mergeTags(
+        $this->getCacheTags(), // Block view builder cache tag.
+        $entity->getCacheTags() // Block entity cache tag.
+      );
+      $cache_tags = Cache::mergeTags(
+        $cache_tags,
+        $plugin->getCacheTags() // Block plugin cache tags.
+      );
+
       // Create the render array for the block as a whole.
       // @see template_preprocess_block().
       $build[$entity_id] = array(
@@ -66,11 +75,7 @@ public function viewMultiple(array $entities = array(), $view_mode = 'full', $la
         '#cache' => [
           'keys' => ['entity_view', 'block', $entity->id()],
           'contexts' => $plugin->getCacheContexts(),
-          'tags' => Cache::mergeTags(
-            $this->getCacheTags(), // Block view builder cache tag.
-            $entity->getCacheTags(), // Block entity cache tag.
-            $plugin->getCacheTags() // Block plugin cache tags.
-          ),
+          'tags' => $cache_tags,
           'max-age' => $plugin->getCacheMaxAge(),
         ],
         '#pre_render' => [
diff --git a/core/modules/block_content/src/Tests/BlockContentCacheTagsTest.php b/core/modules/block_content/src/Tests/BlockContentCacheTagsTest.php
index 582d832..c3a07c4 100644
--- a/core/modules/block_content/src/Tests/BlockContentCacheTagsTest.php
+++ b/core/modules/block_content/src/Tests/BlockContentCacheTagsTest.php
@@ -91,12 +91,14 @@ public function testBlock() {
     // @see \Drupal\block\BlockViewBuilder::viewMultiple()
     $expected_block_cache_keys = ['entity_view', 'block', $block->id()];
     $expected_block_cache_contexts = ['languages:' . LanguageInterface::TYPE_INTERFACE, 'theme'];
-    $expected_block_cache_tags = Cache::mergeTags(['block_view', 'rendered'], $block->getCacheTags(), $block->getPlugin()->getCacheTags());
+    $expected_block_cache_tags = Cache::mergeTags(['block_view', 'rendered'], $block->getCacheTags());
+    $expected_block_cache_tags = Cache::mergeTags($expected_block_cache_tags, $block->getPlugin()->getCacheTags());
 
     // Expected contexts and tags for the BlockContent entity.
     // @see \Drupal\Core\Entity\EntityViewBuilder::getBuildDefaults().
     $expected_entity_cache_contexts = ['theme'];
-    $expected_entity_cache_tags = Cache::mergeTags(['block_content_view'], $this->entity->getCacheTags(), $this->getAdditionalCacheTagsForEntity($this->entity));
+    $expected_entity_cache_tags = Cache::mergeTags(['block_content_view'], $this->entity->getCacheTags());
+    $expected_entity_cache_tags = Cache::mergeTags($expected_entity_cache_tags, $this->getAdditionalCacheTagsForEntity($this->entity));
 
     // Verify that what was render cached matches the above expectations.
     $cid = $this->createCacheId($expected_block_cache_keys, $expected_block_cache_contexts);
diff --git a/core/modules/field/src/Tests/EntityReference/EntityReferenceFormatterTest.php b/core/modules/field/src/Tests/EntityReference/EntityReferenceFormatterTest.php
index 52fdc08..ef66cd2 100644
--- a/core/modules/field/src/Tests/EntityReference/EntityReferenceFormatterTest.php
+++ b/core/modules/field/src/Tests/EntityReference/EntityReferenceFormatterTest.php
@@ -200,7 +200,10 @@ public function testEntityFormatter() {
     $this->assertEqual($build[0]['#markup'], 'default | ' . $this->referencedEntity->label() .  $expected_rendered_name_field_1 . $expected_rendered_body_field_1, sprintf('The markup returned by the %s formatter is correct for an item with a saved entity.', $formatter));
     $expected_cache_tags = Cache::mergeTags(
       \Drupal::entityManager()->getViewBuilder($this->entityType)->getCacheTags(),
-      $this->referencedEntity->getCacheTags(),
+      $this->referencedEntity->getCacheTags()
+    );
+    $expected_cache_tags = Cache::mergeTags(
+      $expected_cache_tags,
       FilterFormat::load('full_html')->getCacheTags()
     );
     $this->assertEqual($build[0]['#cache']['tags'], $expected_cache_tags, format_string('The @formatter formatter has the expected cache tags.', array('@formatter' => $formatter)));
diff --git a/core/modules/system/src/Tests/Entity/EntityCacheTagsTestBase.php b/core/modules/system/src/Tests/Entity/EntityCacheTagsTestBase.php
index 0b365cb..5b8db03 100644
--- a/core/modules/system/src/Tests/Entity/EntityCacheTagsTestBase.php
+++ b/core/modules/system/src/Tests/Entity/EntityCacheTagsTestBase.php
@@ -352,16 +352,32 @@ public function testReferencedEntity() {
     // Generate the cache tags for the (non) referencing entities.
     $referencing_entity_cache_tags = Cache::mergeTags(
       $this->referencingEntity->getCacheTags(),
-      \Drupal::entityManager()->getViewBuilder('entity_test')->getCacheTags(),
+      \Drupal::entityManager()->getViewBuilder('entity_test')->getCacheTags()
+    );
+    $referencing_entity_cache_tags = Cache::mergeTags(
+      $referencing_entity_cache_tags,
       // Includes the main entity's cache tags, since this entity references it.
-      $this->entity->getCacheTags(),
-      $this->getAdditionalCacheTagsForEntity($this->entity),
-      $view_cache_tag,
+      $this->entity->getCacheTags()
+    );
+    $referencing_entity_cache_tags = Cache::mergeTags(
+      $referencing_entity_cache_tags,
+      $this->getAdditionalCacheTagsForEntity($this->entity)
+    );
+    $referencing_entity_cache_tags = Cache::mergeTags(
+      $referencing_entity_cache_tags,
+      $view_cache_tag
+    );
+    $referencing_entity_cache_tags = Cache::mergeTags(
+      $referencing_entity_cache_tags,
       ['rendered']
     );
+
     $non_referencing_entity_cache_tags = Cache::mergeTags(
       $this->nonReferencingEntity->getCacheTags(),
-      \Drupal::entityManager()->getViewBuilder('entity_test')->getCacheTags(),
+      \Drupal::entityManager()->getViewBuilder('entity_test')->getCacheTags()
+    );
+    $non_referencing_entity_cache_tags = Cache::mergeTags(
+      $non_referencing_entity_cache_tags,
       ['rendered']
     );
 
@@ -372,17 +388,29 @@ public function testReferencedEntity() {
       $this->entity->getEntityType()->getListCacheTags(),
       $page_cache_tags
     );
+
     $nonempty_entity_listing_cache_tags = Cache::mergeTags(
       $this->entity->getEntityType()->getListCacheTags(),
-      $this->entity->getCacheTags(),
-      $this->getAdditionalCacheTagsForEntityListing($this->entity),
+      $this->entity->getCacheTags()
+    );
+    $nonempty_entity_listing_cache_tags = Cache::mergeTags(
+      $nonempty_entity_listing_cache_tags,
+      $this->getAdditionalCacheTagsForEntityListing($this->entity)
+    );
+    $nonempty_entity_listing_cache_tags = Cache::mergeTags(
+      $nonempty_entity_listing_cache_tags,
       $page_cache_tags
     );
 
     $this->pass("Test referencing entity.", 'Debug');
     $this->verifyPageCache($referencing_entity_url, 'MISS');
+
     // Verify a cache hit, but also the presence of the correct cache tags.
-    $this->verifyPageCache($referencing_entity_url, 'HIT', Cache::mergeTags($referencing_entity_cache_tags, $page_cache_tags, $page_cache_tags_referencing_entity));
+    $expectedTags = [];
+    $expectedTags = Cache::mergeTags($referencing_entity_cache_tags, $page_cache_tags);
+    $expectedTags = Cache::mergeTags($expectedTags, $page_cache_tags_referencing_entity);
+    $this->verifyPageCache($referencing_entity_url, 'HIT', $expectedTags);
+
     // Also verify the existence of an entity render cache entry.
     $cache_keys = ['entity_view', 'entity_test', $this->referencingEntity->id(), 'full'];
     $cid = $this->createCacheId($cache_keys, $entity_cache_contexts);
@@ -406,9 +434,12 @@ public function testReferencedEntity() {
     $this->pass("Test listing of referencing entities.", 'Debug');
     // Prime the page cache for the listing of referencing entities.
     $this->verifyPageCache($listing_url, 'MISS');
-    // Verify a cache hit, but also the presence of the correct cache tags.
-    $this->verifyPageCache($listing_url, 'HIT', Cache::mergeTags($referencing_entity_cache_tags, $page_cache_tags, $page_cache_tags_referencing_entity));
 
+    // Verify a cache hit, but also the presence of the correct cache tags.
+    $expectedTags = [];
+    $expectedTags = Cache::mergeTags($referencing_entity_cache_tags, $page_cache_tags);
+    $expectedTags = Cache::mergeTags($expectedTags, $page_cache_tags_referencing_entity);
+    $this->verifyPageCache($listing_url, 'HIT', $expectedTags);
 
     $this->pass("Test empty listing.", 'Debug');
     // Prime the page cache for the empty listing.
@@ -629,13 +660,26 @@ public function testReferencedEntity() {
     // Verify cache hits.
     $referencing_entity_cache_tags = Cache::mergeTags(
       $this->referencingEntity->getCacheTags(),
-      \Drupal::entityManager()->getViewBuilder('entity_test')->getCacheTags(),
+      \Drupal::entityManager()->getViewBuilder('entity_test')->getCacheTags()
+    );
+    $referencing_entity_cache_tags = Cache::mergeTags(
+      $referencing_entity_cache_tags,
       ['rendered']
     );
+
+    $nonempty_entity_listing_cache_tags = Cache::mergeTags(
+      $this->entity->getEntityType()->getListCacheTags(),
+      $this->getAdditionalCacheTagsForEntityListing()
+    );
+    $nonempty_entity_listing_cache_tags = Cache::mergeTags(
+      $nonempty_entity_listing_cache_tags,
+      $page_cache_tags
+    );
+
     $this->verifyPageCache($referencing_entity_url, 'HIT', Cache::mergeTags($referencing_entity_cache_tags, $page_cache_tags));
     $this->verifyPageCache($listing_url, 'HIT', $page_cache_tags);
     $this->verifyPageCache($empty_entity_listing_url, 'HIT', $empty_entity_listing_cache_tags);
-    $this->verifyPageCache($nonempty_entity_listing_url, 'HIT', Cache::mergeTags($this->entity->getEntityType()->getListCacheTags(), $this->getAdditionalCacheTagsForEntityListing(), $page_cache_tags));
+    $this->verifyPageCache($nonempty_entity_listing_url, 'HIT', $nonempty_entity_listing_cache_tags);
   }
 
   /**
diff --git a/core/modules/system/src/Tests/Entity/EntityWithUriCacheTagsTestBase.php b/core/modules/system/src/Tests/Entity/EntityWithUriCacheTagsTestBase.php
index 0b6f430..abbcad3 100644
--- a/core/modules/system/src/Tests/Entity/EntityWithUriCacheTagsTestBase.php
+++ b/core/modules/system/src/Tests/Entity/EntityWithUriCacheTagsTestBase.php
@@ -56,7 +56,9 @@ public function testEntityUri() {
       if (count($additional_cache_contexts)) {
         $redirected_cid = $this->createCacheId($cache_keys, Cache::mergeContexts($entity_cache_contexts, $additional_cache_contexts));
       }
-      $expected_cache_tags = Cache::mergeTags($cache_tag, $view_cache_tag, $this->getAdditionalCacheTagsForEntity($this->entity), array($render_cache_tag));
+      $expected_cache_tags = Cache::mergeTags($cache_tag, $view_cache_tag);
+      $expected_cache_tags = Cache::mergeTags($expected_cache_tags, $this->getAdditionalCacheTagsForEntity($this->entity));
+      $expected_cache_tags = Cache::mergeTags($expected_cache_tags, array($render_cache_tag));
       $this->verifyRenderCache($cid, $expected_cache_tags, $redirected_cid);
     }
 
diff --git a/core/modules/views/src/Tests/RenderCacheIntegrationTest.php b/core/modules/views/src/Tests/RenderCacheIntegrationTest.php
index 183e395..e18db42 100644
--- a/core/modules/views/src/Tests/RenderCacheIntegrationTest.php
+++ b/core/modules/views/src/Tests/RenderCacheIntegrationTest.php
@@ -108,7 +108,11 @@ protected function assertCacheTagsForFieldBasedView($do_assert_views_caches) {
       $entity->save();
     }
     // Page 1.
-    $tags_page_1 = Cache::mergeTags($base_tags, $entities[1]->getCacheTags(), $entities[2]->getCacheTags(), $entities[3]->getCacheTags(), $entities[4]->getCacheTags(), $entities[5]->getCacheTags());
+    $tags_page_1 = Cache::mergeTags($base_tags, $entities[1]->getCacheTags());
+    $tags_page_1 = Cache::mergeTags($tags_page_1, $entities[2]->getCacheTags());
+    $tags_page_1 = Cache::mergeTags($tags_page_1, $entities[3]->getCacheTags());
+    $tags_page_1 = Cache::mergeTags($tags_page_1, $entities[4]->getCacheTags());
+    $tags_page_1 = Cache::mergeTags($tags_page_1, $entities[5]->getCacheTags());
     $this->assertViewsCacheTags($view, $tags_page_1, $do_assert_views_caches, $tags_page_1);
     $view->destroy();
     // Page 2.
@@ -186,7 +190,8 @@ protected function assertCacheTagsForEntityBasedView($do_assert_views_caches) {
     $entity->save();
 
     $result_tags_with_entity = Cache::mergeTags($base_tags, $entities[0]->getCacheTags());
-    $render_tags_with_entity = Cache::mergeTags($base_render_tags, $entities[0]->getCacheTags(), ['entity_test_view']);
+    $render_tags_with_entity = Cache::mergeTags($base_render_tags, $entities[0]->getCacheTags());
+    $render_tags_with_entity = Cache::mergeTags($render_tags_with_entity, ['entity_test_view']);
     $this->assertViewsCacheTags($view, $result_tags_with_entity, $do_assert_views_caches, $render_tags_with_entity);
 
 
@@ -196,9 +201,13 @@ protected function assertCacheTagsForEntityBasedView($do_assert_views_caches) {
       $entity->save();
     }
 
-    $new_entities_cache_tags = Cache::mergeTags($entities[1]->getCacheTags(), $entities[2]->getCacheTags(), $entities[3]->getCacheTags(), $entities[4]->getCacheTags(), $entities[5]->getCacheTags());
+    $new_entities_cache_tags = Cache::mergeTags($entities[1]->getCacheTags(), $entities[2]->getCacheTags());
+    $new_entities_cache_tags = Cache::mergeTags($new_entities_cache_tags, $entities[3]->getCacheTags());
+    $new_entities_cache_tags = Cache::mergeTags($new_entities_cache_tags, $entities[4]->getCacheTags());
+    $new_entities_cache_tags = Cache::mergeTags($new_entities_cache_tags, $entities[5]->getCacheTags());
     $result_tags_page_1 = Cache::mergeTags($base_tags, $new_entities_cache_tags);
-    $render_tags_page_1 = Cache::mergeTags($base_render_tags, $new_entities_cache_tags, ['entity_test_view']);
+    $render_tags_page_1 = Cache::mergeTags($base_render_tags, $new_entities_cache_tags);
+    $render_tags_page_1 = Cache::mergeTags($render_tags_page_1, ['entity_test_view']);
     $this->assertViewsCacheTags($view, $result_tags_page_1, $do_assert_views_caches, $render_tags_page_1);
   }
 
