From 48e1c0dc8c1d2450cfcd439ebf89102074396933 Mon Sep 17 00:00:00 2001 From: eileen Date: Wed, 19 Jun 2013 13:45:16 +1200 Subject: [PATCH] fix bug in handling unique fields as a return value highlighted by test --- api/v3/utils.php | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/api/v3/utils.php b/api/v3/utils.php index 432b0123c7..4288da156e 100644 --- a/api/v3/utils.php +++ b/api/v3/utils.php @@ -550,19 +550,21 @@ function _civicrm_api3_dao_set_filter(&$dao, $params, $unique = TRUE, $entity) { $options['return']['id'] = TRUE;// ensure 'id' is included $allfields = _civicrm_api3_get_unique_name_array($dao); $returnMatched = array_intersect(array_keys($options['return']), $allfields); - $returnUniqueMatched = array_intersect( - array_diff(// not already matched on the field names - $options['return'], - $returnMatched), - array_flip($allfields)// but a match for the field keys - ); - foreach ($returnMatched as $returnValue) { - $dao->selectAdd($returnValue); + $dao->selectAdd($returnValue); } + + $unmatchedFields = array_diff(// not already matched on the field names + array_keys($options['return']), + $returnMatched + ); + + $returnUniqueMatched = array_intersect( + $unmatchedFields, + array_flip($allfields)// but a match for the field keys + ); foreach ($returnUniqueMatched as $uniqueVal){ $dao->selectAdd($allfields[$uniqueVal]); - } } } -- 2.25.1