//delete the contact id from recently view
CRM_Utils_Recent::delContact($id);
-
- // Update the group contact cache
- if ($restore) {
- CRM_Contact_BAO_GroupContactCache::remove();
- }
- else {
- CRM_Contact_BAO_GroupContactCache::removeContact($id);
- }
+ self::updateContactCache($id, empty($restore));
// delete any dupe cache entry
CRM_Core_BAO_PrevNextCache::deleteItem($id);
return TRUE;
}
+ /**
+ * Action to update any caches relating to a recently update contact.
+ *
+ * I was going to call this from delete as well as from create to ensure the delete is being
+ * done whenever a contact is set to is_deleted=1 BUT I found create is already over-aggressive in
+ * that regard so adding it to delete seems to be enough to remove it from CRM_Contact_BAO_Contact_Permission
+ * where the call involved a subquery that was locking the table.
+ *
+ * @param int $contactID
+ * @param bool $isTrashed
+ */
+ public static function updateContactCache($contactID, $isTrashed = FALSE) {
+
+ if ($isTrashed) {
+ CRM_Contact_BAO_GroupContactCache::removeContact($contactID);
+ // This has been moved to here from CRM_Contact_BAO_Contact_Permission as that was causing
+ // a table-locking query. It still seems a bit inadequate as it assumes the acl users can't see deleted
+ // but this should not cause any change as long as contacts are not being trashed outside the
+ // main functions for that.
+ CRM_Core_DAO::executeQuery('DELETE FROM civicrm_acl_contact_cache WHERE contact_id = %1', array(1 => array($contactID, 'Integer')));
+ }
+ else {
+ CRM_Contact_BAO_GroupContactCache::remove();
+ }
+ }
+
/**
* Delete the image of a contact.
*