Details
Description
When sending a mass mailing via CiviMail, there is occasionally an SQL failure which causes the mass mailing to be listed indefinitely as in a "Running" status. This issue happens with any SQL error.
In the last issue where this happened, the SQL failure was in the file "/CRM/Activity/BAO/Activity.php" at line number 477.
The failure message was : "Duplicate entry '4756-17516' for key 'UI_activity_target_contact_id"
Here is the original failing code fragment:
while (!empty($values))
{ $input = array_splice($values, 0, CRM_Core_DAO::BULK_INSERT_COUNT); $str = implode(',', $input); $sql = "INSERT INTO civicrm_activity_target ( activity_id, target_contact_id ) VALUES $str;"; CRM_Core_DAO::executeQuery($sql); }I fixed the issue by changing the SQL statement as follows:
$sql = "INSERT IGNORE INTO civicrm_activity_target ( activity_id, target_contact_id ) VALUES $str;";
(This seems to be related to the existing issue at: issues.civicrm.org/jira/browse/CRM-7484 )