From 58a6dbb8a4db115a2ab1ca7304553f3ffb8962ec Mon Sep 17 00:00:00 2001
From: Alex Pott <alex.a.pott@googlemail.com>
Date: Fri, 24 Jul 2015 16:54:24 +0100
Subject: [PATCH] Issue #2525884 by jesperjb, joshi.rohit100, Berdir: Avoid
 unecessary cache tag invalidations in ConfigEntityBase and aggregator Item
 entity

---
 core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php       | 2 --
 core/modules/aggregator/src/Entity/Item.php                   | 4 +++-
 .../Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php     | 4 ----
 3 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php
index ea2c22c41d68..db0841221a24 100644
--- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php
+++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php
@@ -192,8 +192,6 @@ public function enable() {
    * {@inheritdoc}
    */
   public function disable() {
-    // An entity was disabled, invalidate its own cache tag.
-    Cache::invalidateTags($this->getCacheTagsToInvalidate());
     return $this->setStatus(FALSE);
   }
 
diff --git a/core/modules/aggregator/src/Entity/Item.php b/core/modules/aggregator/src/Entity/Item.php
index 725f6478be6d..92c3b7963a9c 100644
--- a/core/modules/aggregator/src/Entity/Item.php
+++ b/core/modules/aggregator/src/Entity/Item.php
@@ -225,7 +225,9 @@ public function postSave(EntityStorageInterface $storage, $update = TRUE) {
     // handles the regular cases. The Item entity has one special case: a newly
     // created Item is *also* associated with a Feed, so we must invalidate the
     // associated Feed's cache tag.
-    Cache::invalidateTags($this->getCacheTagsToInvalidate());
+    if (!$update) {
+      Cache::invalidateTags($this->getCacheTagsToInvalidate());
+    }
   }
 
   /**
diff --git a/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php b/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php
index ba9171074b24..fa1c006a2642 100644
--- a/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php
+++ b/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php
@@ -376,10 +376,6 @@ public function testEnable() {
    * @depends testSetStatus
    */
   public function testDisable() {
-    $this->cacheTagsInvalidator->expects($this->once())
-      ->method('invalidateTags')
-      ->with(array('config:test_provider.'  . $this->entityTypeId . '.' . $this->id));
-
     $this->entity->setStatus(TRUE);
     $this->assertSame($this->entity, $this->entity->disable());
     $this->assertFalse($this->entity->status());
-- 
GitLab