Eileen has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/350359 )

Change subject: Remove call to class_api in favour of civicrm_api3.
......................................................................

Remove call to class_api in favour of civicrm_api3.

    class_api is causing test failures when the updated mysqli driver tries to 
free memory

Change-Id: Ic723bc45be5f05f7fe9e287679f07d5163eafe6f
---
M sites/all/modules/wmf_civicrm/recurring.inc
M sites/all/modules/wmf_civicrm/wmf_civicrm.module
2 files changed, 18 insertions(+), 21 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/crm 
refs/changes/59/350359/1

diff --git a/sites/all/modules/wmf_civicrm/recurring.inc 
b/sites/all/modules/wmf_civicrm/recurring.inc
index 3e99e1f..b8f4b77 100644
--- a/sites/all/modules/wmf_civicrm/recurring.inc
+++ b/sites/all/modules/wmf_civicrm/recurring.inc
@@ -133,28 +133,25 @@
         $error_message = t('`contribution_recur_id` must be set and not 
empty.');
         throw new WmfException('IMPORT_SUBSCRIPTION', $error_message);
     }
-
-    $api = civicrm_api_classapi();
-    $update_params = array(
+    try {
+      $result = civicrm_api3('Contribution', 'create', array(
         'id' => $contribution_id,
         'contribution_recur_id' => $contribution_recur_id,
-
-        'version' => 3,
-    );
-    if ( !$api->Contribution->Create($update_params) ) {
-        $error_message = t(
-            'There was a problem linking the contribution [!contribution_id] 
to the recurring contribution [!contribution_recur_id]: !msg',
-            array(
-                '!contribution_id' => $contribution_id,
-                '!contribution_recur_id' => $contribution_recur_id,
-                '!msg' => $api->errorMsg(),
-            )
-        );
-        throw new WmfException('IMPORT_SUBSCRIPTION', $error_message);
-    } else {
-        watchdog( 'wmf_civicrm', 'Successfully linked the contribution  
[!contribution_id] to the recurring contribution [!contribution_recur_id]', 
array( '!contribution_id' => $contribution_id, '!contribution_recur_id' => 
$contribution_recur_id ) );
-        return true;
+      ));
     }
+    catch (CiviCRM_API3_Exception $e) {
+      $error_message = t(
+        'There was a problem linking the contribution [!contribution_id] to 
the recurring contribution [!contribution_recur_id]: !msg',
+        array(
+          '!contribution_id' => $contribution_id,
+          '!contribution_recur_id' => $contribution_recur_id,
+          '!msg' => $e->getMessage(),
+        )
+      );
+      throw new WmfException('IMPORT_SUBSCRIPTION', $error_message);
+    }
+    watchdog( 'wmf_civicrm', 'Successfully linked the contribution  
[!contribution_id] to the recurring contribution [!contribution_recur_id]', 
array( '!contribution_id' => $contribution_id, '!contribution_recur_id' => 
$contribution_recur_id ) );
+    return true;
 }
 
 /**
diff --git a/sites/all/modules/wmf_civicrm/wmf_civicrm.module 
b/sites/all/modules/wmf_civicrm/wmf_civicrm.module
index ba78a5d..1f22ed3 100644
--- a/sites/all/modules/wmf_civicrm/wmf_civicrm.module
+++ b/sites/all/modules/wmf_civicrm/wmf_civicrm.module
@@ -1883,8 +1883,8 @@
             $msg['direct_mail_appeal'] = "Mediander";
             break;
         default:
-            $values = civicrm_api_option_group( 
wmf_civicrm_get_direct_mail_field_option_name() );
-            if ( !array_key_exists( $msg['utm_campaign'], $values ) ) {
+            $directMailOptions = wmf_civicrm_get_options('Contribution', 
wmf_civicrm_get_custom_field_name('Appeal'));
+            if ( !array_key_exists( $msg['utm_campaign'], 
$directMailOptions['values'] ) ) {
               
wmf_civicrm_ensure_option_value_exists(wmf_civicrm_get_direct_mail_field_option_name(),
 $msg['utm_campaign']);
             }
             $msg['direct_mail_appeal'] = $msg['utm_campaign'];

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic723bc45be5f05f7fe9e287679f07d5163eafe6f
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/crm
Gerrit-Branch: master
Gerrit-Owner: Eileen <emcnaugh...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to