Skip to content

Commit

Permalink
CRM-20789 Add check based on mailing_type following chat with Tim to …
Browse files Browse the repository at this point in the history
…ensure only deailing with AB tests
  • Loading branch information
seamuslee001 committed Jun 29, 2017
1 parent abf4cee commit b6f5751
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions CRM/Mailing/Event/BAO/Unsubscribe.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,12 @@ public static function &unsub_from_mailing($job_id, $queue_id, $hash, $return =
WHERE $job.id = " . CRM_Utils_Type::escape($job_id, 'Integer'));
$do->fetch();
$mailing_id = $do->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');

// If $entity is null then most likely we are dealing with an AB test
if (empty($entity)) {
// If $entity is null and $mailing_Type is either winner or experiment then we are deailing with an AB test
$abtest_types = array('experiment', 'winner');
if (empty($entity) && in_array($mailing_type, $abtest_types)) {
$mailing_id_a = CRM_Core_DAO::getFieldValue('CRM_Mailing_DAO_MailingAB', $mailing_id, 'mailing_id_a', 'mailing_id_b');
$field = 'mailing_id_b';
if (empty($mailing_id_a)) {
Expand All @@ -170,7 +172,7 @@ public static function &unsub_from_mailing($job_id, $queue_id, $hash, $return =
}
$jobJoin = "INNER JOIN $ab ON $ab.mailing_id_a = $mg.mailing_id
INNER JOIN $job ON $job.mailing_id = $ab.$field";
$entity = CRM_Core_DAO::getFieldValue('CRM_Mailing_DAO_MailingGroup', $maiing_id_a, 'entity_table', 'mailing_id');
$entity = CRM_Core_DAO::getFieldValue('CRM_Mailing_DAO_MailingGroup', $mailing_id_a, 'entity_table', 'mailing_id');
}
else {
$jobJoin = "INNER JOIN $job ON $job.mailing_id = $mg.mailing_id";
Expand Down

0 comments on commit b6f5751

Please sign in to comment.