From b49578761c92438b5450124876317fb86111cb52 Mon Sep 17 00:00:00 2001 From: "deb.monish" Date: Mon, 4 Sep 2017 23:32:43 +0530 Subject: [PATCH] additional fix --- CRM/Contact/BAO/Group.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/CRM/Contact/BAO/Group.php b/CRM/Contact/BAO/Group.php index 397c8b2554..7f61296ca4 100644 --- a/CRM/Contact/BAO/Group.php +++ b/CRM/Contact/BAO/Group.php @@ -1388,16 +1388,19 @@ WHERE {$whereClause}"; */ public static function filterActiveGroups($parentArray) { if (count($parentArray) > 1) { - foreach ($parentArray as $key => $groupId) { - $isActive = civicrm_api3('Group', 'getvalue', array( - 'id' => $groupId, - 'return' => 'is_active', - )); - if (!$isActive) { + $result = civicrm_api3('Group', 'get', array( + 'id' => array('IN' => $parentArray), + 'is_active' => TRUE, + 'return' => 'id', + )); + $activeParentGroupIDs = CRM_Utils_Array::collect('id', $result['values']); + foreach ($parentArray as $key => $groupID) { + if (!array_key_exists($groupID, $activeParentGroupIDs)) { unset($parentArray[$key]); } } } + return reset($parentArray); } -- 2.25.1