From 4110b451d51a010559af6e5686fad6e62f1dfd11 Mon Sep 17 00:00:00 2001 From: tschuettler Date: Tue, 27 Sep 2016 11:49:41 +0200 Subject: [PATCH] Update Mailing.php Replace parent check with && --- CRM/Mailing/BAO/Mailing.php | 42 ++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/CRM/Mailing/BAO/Mailing.php b/CRM/Mailing/BAO/Mailing.php index de6535a874..4049a5367f 100644 --- a/CRM/Mailing/BAO/Mailing.php +++ b/CRM/Mailing/BAO/Mailing.php @@ -925,20 +925,19 @@ ORDER BY i.contact_id, i.{$tempColumn} $senderId = $session->get('userID'); list($aclJoin, $aclWhere) = CRM_ACL_BAO_ACL::buildAcl($senderId); - if (array_key_exists('test_group', $testParams)) { - if (array_key_exists($testParams['test_group'], CRM_Core_PseudoConstant::group())) { - $contacts = civicrm_api('contact', 'get', array( - 'version' => 3, - 'group' => $testParams['test_group'], - 'return' => 'id', - 'options' => array( - 'limit' => 100000000000, - ), - ) - ); + if (!empty($testParams['test_group']) && array_key_exists($testParams['test_group'], CRM_Core_PseudoConstant::group())) { + $contacts = civicrm_api('contact', 'get', array( + 'version' => 3, + 'group' => $testParams['test_group'], + 'return' => 'id', + 'options' => array( + 'limit' => 100000000000, + ), + ) + ); - foreach (array_keys($contacts['values']) as $groupContact) { - $query = " + foreach (array_keys($contacts['values']) as $groupContact) { + $query = " SELECT civicrm_email.id AS email_id, civicrm_email.is_primary as is_primary, civicrm_email.is_bulkmail as is_bulkmail @@ -955,15 +954,14 @@ AND contact_a.is_opt_out = 0 GROUP BY civicrm_email.id ORDER BY civicrm_email.is_bulkmail DESC "; - $dao = CRM_Core_DAO::executeQuery($query); - if ($dao->fetch()) { - $params = array( - 'job_id' => $testParams['job_id'], - 'email_id' => $dao->email_id, - 'contact_id' => $groupContact, - ); - CRM_Mailing_Event_BAO_Queue::create($params); - } + $dao = CRM_Core_DAO::executeQuery($query); + if ($dao->fetch()) { + $params = array( + 'job_id' => $testParams['job_id'], + 'email_id' => $dao->email_id, + 'contact_id' => $groupContact, + ); + CRM_Mailing_Event_BAO_Queue::create($params); } } } -- 2.25.1