Eileen has uploaded a new change for review. ( 
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, 19 insertions(+), 19 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/crm 
refs/changes/29/351129/1

diff --git a/sites/all/modules/wmf_civicrm/wmf_civicrm.module 
b/sites/all/modules/wmf_civicrm/wmf_civicrm.module
index ef2b81f..71cac41 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,
+        $result = civicrm_api3('Contact', 'Get', array(
+            'organization_name' => $msg['soft_credit_to'],
+            'sequential' => 1,
         ) );
-        if ( count( $api->values ) !== 1 ) {
+        if ( $result['count'] !== 1 ) {
             throw new WmfException(
                 'INVALID_MESSAGE',
                 "Bad soft credit target, [${msg['soft_credit_to']}]"
             );
         }
-        $soft_credit_contact = $api->values[0];
+        $soft_credit_contact = $result['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 ) {
-                               // 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;
+                 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;
+      }
+                       $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: newchange
Gerrit-Change-Id: Ie512256c49b0fb1438d8004571b7f9fbbf63cf7e
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/crm
Gerrit-Branch: master
Gerrit-Owner: Eileen <[email protected]>

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

Reply via email to