Skip to content

Commit

Permalink
Merge pull request #16239 from MegaphoneJon/mailing-60-522
Browse files Browse the repository at this point in the history
mailing#60: Fix regression where `is_bulkmail` flag isn't respected
  • Loading branch information
eileenmcnaughton authored Jan 9, 2020
2 parents a80b558 + 50efb87 commit 9eee721
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CRM/Mailing/BAO/Recipients.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public static function mailingQuery(
// if any email is marked on_hold =1 or contact is deceased after mailing is submitted
// then it should be get skipped while preparing event_queue
// event_queue list is prepared when mailing job gets started.
$additionalJoin = " INNER JOIN civicrm_email e ON (r.email_id = e.id AND e.on_hold = 0 AND e.is_primary = 1)
$additionalJoin = " INNER JOIN civicrm_email e ON (r.email_id = e.id AND e.on_hold = 0)
INNER JOIN civicrm_contact c on (c.id = r.contact_id AND c.is_deceased <> 1 AND c.do_not_email = 0 AND c.is_opt_out = 0)
";
}
Expand Down
32 changes: 32 additions & 0 deletions tests/phpunit/api/v3/JobProcessMailingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,38 @@ public function testDecesasedRecepient() {

}

/**
* Test that "multiple bulk email recipients" setting is respected.
*/
public function testMultipleBulkRecipients() {
Civi::settings()->add([
'civimail_multiple_bulk_emails' => 1,
]);
$contactID = $this->individualCreate(['first_name' => 'test recipient']);
$email1 = $this->callAPISuccess('email', 'create', [
'contact_id' => $contactID,
'email' => 'mail1@example.org',
'is_bulkmail' => 1,
]);
$email2 = $this->callAPISuccess('email', 'create', [
'contact_id' => $contactID,
'email' => 'mail2@example.org',
'is_bulkmail' => 1,
]);
$this->callAPISuccess('group_contact', 'create', [
'contact_id' => $contactID,
'group_id' => $this->_groupID,
'status' => 'Added',
]);
$mailing = $this->callAPISuccess('mailing', 'create', $this->_params);
$this->assertEquals(2, $this->callAPISuccess('MailingRecipients', 'get', ['mailing_id' => $mailing['id']])['count']);
$this->callAPISuccess('job', 'process_mailing', []);
$this->_mut->assertRecipients([['mail1@example.org'], ['mail2@example.org']]);
// Don't leave data lying around for other tests to screw up on.
$this->callAPISuccess('Email', 'delete', ['id' => $email1['id']]);
$this->callAPISuccess('Email', 'delete', ['id' => $email2['id']]);
}

/**
* Test pause and resume on Mailing.
*/
Expand Down

0 comments on commit 9eee721

Please sign in to comment.