jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/351129 )

Change subject: Further removal of class_api3 call in favour of civicrm_api3.
......................................................................


Further removal of class_api3 call in favour of civicrm_api3.

Change-Id: Ie512256c49b0fb1438d8004571b7f9fbbf63cf7e
---
M sites/all/modules/wmf_civicrm/wmf_civicrm.module
1 file changed, 16 insertions(+), 16 deletions(-)

Approvals:
  jenkins-bot: Verified
  Ejegg: Looks good to me, approved



diff --git a/sites/all/modules/wmf_civicrm/wmf_civicrm.module 
b/sites/all/modules/wmf_civicrm/wmf_civicrm.module
index ef2b81f..62de2ce 100644
--- a/sites/all/modules/wmf_civicrm/wmf_civicrm.module
+++ b/sites/all/modules/wmf_civicrm/wmf_civicrm.module
@@ -294,21 +294,20 @@
 
     // Look up soft credit contact.
     if ( !empty( $msg['soft_credit_to'] ) ) {
-        $api = civicrm_api_classapi();
-        $success = $api->Contact->Get( array(
-            'organization_name' => $msg['soft_credit_to'],
 
-            'version' => 3,
+        $soft_credit_contact = civicrm_api3('Contact', 'Get', array(
+            'organization_name' => $msg['soft_credit_to'],
+            'sequential' => 1,
+            'return' => 'id',
         ) );
-        if ( count( $api->values ) !== 1 ) {
+        if ( $soft_credit_contact['count'] !== 1 ) {
             throw new WmfException(
                 'INVALID_MESSAGE',
                 "Bad soft credit target, [${msg['soft_credit_to']}]"
             );
         }
-        $soft_credit_contact = $api->values[0];
         # FIXME: awkward to have the two fields.
-        $msg['soft_credit_to_id'] = $soft_credit_contact->id;
+        $msg['soft_credit_to_id'] = $soft_credit_contact['id'];
     }
 
     // Insert the contribution record.
@@ -2966,18 +2965,19 @@
                        $contact_id = $contribution->contact_id;
                        $total_amount = $contribution->total_amount;
                } else {
-                       $api = civicrm_api_classapi();
-                       $result = $api->Contribution->get( array(
-                               'id' => $contribution->id,
-                       ) );
-                       if ( !$result || count( $api->values ) != 1 ) {
+                       try {
+                               $db_contribution = civicrm_api3('Contribution', 
'getsingle', array(
+                                       'id' => $contribution->id,
+                                       'return' => array('contact_id', 
'total_amount', 'receive_date'),
+                               ));
+                       }
+                       catch (CiviCRM_API3_Exception $e) {
                                // can't get the data, skip wmf_donor updates
                                break;
                        }
-                       $db_contribution = $api->values[0];
-                       $receive_date = $db_contribution->receive_date;
-                       $contact_id = $db_contribution->contact_id;
-                       $total_amount = $db_contribution->total_amount;
+                       $receive_date = $db_contribution['receive_date'];
+                       $contact_id = $db_contribution['contact_id'];
+                       $total_amount = $db_contribution['total_amount'];
                }
 
                // Update the wmf_donor data.  Set the is_YYYY_donor column to 
true

-- 
To view, visit https://gerrit.wikimedia.org/r/351129
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ie512256c49b0fb1438d8004571b7f9fbbf63cf7e
Gerrit-PatchSet: 5
Gerrit-Project: wikimedia/fundraising/crm
Gerrit-Branch: master
Gerrit-Owner: Eileen <[email protected]>
Gerrit-Reviewer: Ejegg <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to