From be81f101e54e7fb52c6978e2c4488e3efa6f2e82 Mon Sep 17 00:00:00 2001 From: eileen Date: Wed, 2 Dec 2015 04:32:10 +1300 Subject: [PATCH] CRM-17640 re-use contact apiQuery for contribution --- api/v3/Contribution.php | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/api/v3/Contribution.php b/api/v3/Contribution.php index 3003eb5f37..dc1a9861ab 100644 --- a/api/v3/Contribution.php +++ b/api/v3/Contribution.php @@ -241,18 +241,17 @@ function _civicrm_api3_contribution_delete_spec(&$params) { function civicrm_api3_contribution_get($params) { $mode = CRM_Contact_BAO_Query::MODE_CONTRIBUTE; - list($dao, $query) = _civicrm_api3_get_query_object($params, $mode, 'Contribution'); - - $contribution = array(); - while ($dao->fetch()) { - //CRM-8662 - $contribution_details = $query->store($dao); - $softContribution = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($dao->contribution_id, TRUE); - $contribution[$dao->contribution_id] = array_merge($contribution_details, $softContribution); + $returnProperties = CRM_Contribute_BAO_Query::defaultReturnProperties($mode); + + $contributions = _civicrm_api3_get_using_query_object('Contribution', $params, array(), NULL, $mode, $returnProperties); + + foreach ($contributions as $id => $contribution) { + $softContribution = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($id, TRUE); + $contributions[$id] = array_merge($contribution, $softContribution); // format soft credit for backward compatibility - _civicrm_api3_format_soft_credit($contribution[$dao->contribution_id]); + _civicrm_api3_format_soft_credit($contributions[$id]); } - return civicrm_api3_create_success($contribution, $params, 'Contribution', 'get'); + return civicrm_api3_create_success($contributions, $params, 'Contribution', 'get'); } /** -- 2.25.1