From a8578678d9e0cb9fc75bf21d73abdc9824ad6683 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frank=20J=2E=20G=C3=B3mez?= Date: Sat, 15 Apr 2017 16:14:42 -0400 Subject: [PATCH] CRM-20435: Conservative replacement of SQL-based activityContact creation with DAO-based approach. --- CRM/Activity/BAO/Activity.php | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/CRM/Activity/BAO/Activity.php b/CRM/Activity/BAO/Activity.php index d99a6c9ab9fb..c9207aabfe26 100644 --- a/CRM/Activity/BAO/Activity.php +++ b/CRM/Activity/BAO/Activity.php @@ -370,18 +370,16 @@ public static function create(&$params) { self::deleteActivityContact($activityId, $assigneeID); } - $values = array(); foreach ($params['assignee_contact_id'] as $acID) { if ($acID) { - $values[] = "( $activityId, $acID, $assigneeID )"; + $assigneeParams = array( + 'activity_id' => $activityId, + 'contact_id' => $acID, + 'record_type_id' => $assigneeID, + ); + CRM_Activity_BAO_ActivityContact::create($assigneeParams); } } - while (!empty($values)) { - $input = array_splice($values, 0, CRM_Core_DAO::BULK_INSERT_COUNT); - $str = implode(',', $input); - $sql = "INSERT IGNORE INTO civicrm_activity_contact ( activity_id, contact_id, record_type_id ) VALUES $str;"; - CRM_Core_DAO::executeQuery($sql); - } } else { $assignmentParams['contact_id'] = $params['assignee_contact_id']; @@ -425,19 +423,16 @@ public static function create(&$params) { self::deleteActivityContact($activityId, $targetID); } - $values = array(); foreach ($params['target_contact_id'] as $tid) { if ($tid) { - $values[] = "( $activityId, $tid, $targetID )"; + $targetContactParams = array( + 'activity_id' => $activityId, + 'contact_id' => $tid, + 'record_type_id' => $targetID, + ); + CRM_Activity_BAO_ActivityContact::create($targetContactParams); } } - - while (!empty($values)) { - $input = array_splice($values, 0, CRM_Core_DAO::BULK_INSERT_COUNT); - $str = implode(',', $input); - $sql = "INSERT IGNORE INTO civicrm_activity_contact ( activity_id, contact_id, record_type_id ) VALUES $str;"; - CRM_Core_DAO::executeQuery($sql); - } } else { $targetParams['contact_id'] = $params['target_contact_id'];