$groupIDs = array($groupID);
self::remove($groupIDs);
-
$processed = FALSE;
+ $tempTable = 'civicrm_temp_group_contact_cache' . rand(0,2000);
foreach (array($sql, $sqlB) as $selectSql) {
if (!$selectSql) {
continue;
}
- $insertSql = "INSERT IGNORE INTO civicrm_group_contact_cache (group_id,contact_id) ($selectSql);";
+ $insertSql = "CREATE TEMPORARY TABLE $tempTable ($selectSql);";
$processed = TRUE;
$result = CRM_Core_DAO::executeQuery($insertSql);
+ CRM_Core_DAO::executeQuery(
+ "INSERT IGNORE INTO civicrm_group_contact_cache (contact_id, group_id)
+ SELECT DISTINCT $idName, group_id FROM $tempTable
+ ");
+ CRM_Core_DAO::executeQuery(" DROP TABLE $tempTable");
}
+
self::updateCacheTime($groupIDs, $processed);
if ($group->children) {