From d6b7184b2d3b2d8ec9b9d3ed6c26efbcd3820a11 Mon Sep 17 00:00:00 2001 From: eileen Date: Tue, 9 Jul 2019 18:39:50 +1200 Subject: [PATCH] dev/core#1108 Use api call to retrieve mailing_id This replaces several lines of code with one & avoids ad hoc handling on translation --- CRM/Mailing/Event/BAO/Unsubscribe.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/CRM/Mailing/Event/BAO/Unsubscribe.php b/CRM/Mailing/Event/BAO/Unsubscribe.php index f6c4771e28..425820aad8 100644 --- a/CRM/Mailing/Event/BAO/Unsubscribe.php +++ b/CRM/Mailing/Event/BAO/Unsubscribe.php @@ -125,6 +125,8 @@ WHERE email = %2 * * @return array|null * $groups Array of all groups from which the contact was removed, or null if the queue event could not be found. + * + * @throws \CiviCRM_API3_Exception */ public static function &unsub_from_mailing($job_id, $queue_id, $hash, $return = FALSE) { // First make sure there's a matching queue event. @@ -152,12 +154,7 @@ WHERE email = %2 $abObject = new CRM_Mailing_DAO_MailingAB(); $ab = $abObject->getTableName(); - //We Need the mailing Id for the hook... - $do->query("SELECT $job.mailing_id as mailing_id - FROM $job - WHERE $job.id = " . CRM_Utils_Type::escape($job_id, 'Integer')); - $do->fetch(); - $mailing_id = $do->mailing_id; + $mailing_id = civicrm_api3('MailingJob', 'getvalue', ['id' => $job_id, 'return' => 'mailing_id']); $mailing_type = CRM_Core_DAO::getFieldValue('CRM_Mailing_DAO_Mailing', $mailing_id, 'mailing_type', 'id'); $entity = CRM_Core_DAO::getFieldValue('CRM_Mailing_DAO_MailingGroup', $mailing_id, 'entity_table', 'mailing_id'); -- 2.25.1