Remove cached smart group entries when removing from a group
authoreileen <emcnaughton@wikimedia.org>
Thu, 27 Jun 2019 13:23:43 +0000 (01:23 +1200)
committereileen <emcnaughton@wikimedia.org>
Fri, 28 Jun 2019 00:36:11 +0000 (12:36 +1200)
In 5.15 we have added fixes for smart groups regarding removed entries. Possibly related to this but also possibly pre-existing
I'm seeing contacts who have been removed from smart groups showing up after removal in search results for the duration of the smart group cache.

Regardless the fix feels safe, sensible and correct so I'm comfortable targetting the rc without further research as to whether it
is a regression. The fix being removal of the cache entry when the group entry is removed.

CRM/Contact/BAO/GroupContact.php

index 141b0ffeb22da9a58d1927e64c271cc8ea920c4e..2e1dbd503b62306c52c87fd78a57e661e7836a9f 100644 (file)
@@ -239,6 +239,8 @@ class CRM_Contact_BAO_GroupContact extends CRM_Contact_DAO_GroupContact {
         CRM_Contact_BAO_SubscriptionHistory::create($historyParams);
         $groupContact->status = $status;
         $groupContact->save();
+        // Remove any rows from the group contact cache so it disappears straight away from smart groups.
+        CRM_Contact_BAO_GroupContactCache::removeContact($contactId, $groupId);
       }
     }