stop trying to retrieve value from non-existant parameter
authoreileenmcnaughton <eileen@fuzion.co.nz>
Mon, 29 Jun 2015 21:55:10 +0000 (21:55 +0000)
committereileenmcnaughton <eileen@fuzion.co.nz>
Mon, 29 Jun 2015 21:55:10 +0000 (21:55 +0000)
CRM/Contribute/Form/Contribution/Confirm.php
CRM/Member/BAO/Membership.php

index a234d0fa4bfa71ae8304990ff3f123b55e52a179..68e654c6371270b1024301c826b5ef48af9a7f4c 100644 (file)
@@ -1545,15 +1545,20 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
       $isProcessSeparateMembershipTransaction = $this->isSeparateMembershipTransaction($this->_id, $this->_values['amount_block_is_active']);
 
       if ($this->_values['amount_block_is_active']) {
-        $contributionTypeId = $this->_values['financial_type_id'];
+        $financialTypeID = $this->_values['financial_type_id'];
       }
       else {
-        $contributionTypeId = CRM_Utils_Array::value('financial_type_id', $membershipType, CRM_Utils_Array::value('financial_type_id', $membershipParams));
+        $financialTypeID = CRM_Utils_Array::value('financial_type_id', $membershipType, CRM_Utils_Array::value('financial_type_id', $membershipParams));
+      }
+
+      if (CRM_Utils_Array::value('membership_source', $this->_params)) {
+        $membershipParams['contribution_source'] = $this->_params['membership_source'];
       }
 
       CRM_Member_BAO_Membership::postProcessMembership($membershipParams, $contactID,
-        $this, $premiumParams, $customFieldsFormatted, $fieldTypes, $membershipType, $membershipTypeIDs, $isPaidMembership, $this->_membershipId, $isProcessSeparateMembershipTransaction, $contributionTypeId,
+        $this, $premiumParams, $customFieldsFormatted, $fieldTypes, $membershipType, $membershipTypeIDs, $isPaidMembership, $this->_membershipId, $isProcessSeparateMembershipTransaction, $financialTypeID,
         $membershipLineItems, $isPayLater, $isPending);
+
       $this->assign('membership_assign', TRUE);
       $this->set('membershipTypeID', $membershipParams['selectMembership']);
     }
index 14d0d7e54783dbd17a9eef0654fb5f0a6449768d..1d2b3839af7993cf01317426dfa8fc50b4e7ab95 100644 (file)
@@ -1123,7 +1123,7 @@ AND civicrm_membership.is_test = %2";
    *
    * @param bool $isProcessSeparateMembershipTransaction
    *
-   * @param int $defaultContributionTypeID
+   * @param int $financialTypeID
    * @param array $membershipLineItems
    *   Line items specific to membership payment that is separate to contribution.
    * @param bool $isPayLater
@@ -1134,23 +1134,11 @@ AND civicrm_membership.is_test = %2";
   public static function postProcessMembership(
     $membershipParams, $contactID, &$form, $premiumParams,
     $customFieldsFormatted = NULL, $includeFieldTypes = NULL, $membershipDetails, $membershipTypeIDs, $isPaidMembership, $membershipID,
-    $isProcessSeparateMembershipTransaction, $defaultContributionTypeID, $membershipLineItems, $isPayLater, $isPending) {
+    $isProcessSeparateMembershipTransaction, $financialTypeID, $membershipLineItems, $isPayLater, $isPending) {
     $result = $membershipContribution = NULL;
     $isTest = CRM_Utils_Array::value('is_test', $membershipParams, FALSE);
     $errors = $createdMemberships = $paymentResult = array();
 
-    //@todo move this into the calling function & pass in the correct financialTypeID
-    if (isset($paymentParams['financial_type'])) {
-      $financialTypeID = $paymentParams['financial_type'];
-    }
-    else {
-      $financialTypeID = $defaultContributionTypeID;
-    }
-
-    if (CRM_Utils_Array::value('membership_source', $form->_params)) {
-      $membershipParams['contribution_source'] = $form->_params['membership_source'];
-    }
-
     if ($isPaidMembership) {
       if ($isProcessSeparateMembershipTransaction) {
         // If we have 2 transactions only one can use the invoice id.
@@ -2013,9 +2001,7 @@ INNER JOIN  civicrm_contact contact ON ( contact.id = membership.contact_id AND
   public static function processSecondaryFinancialTransaction($contactID, &$form, $tempParams, $isTest, $lineItems, $minimumFee, $financialTypeID) {
     $financialType = new CRM_Financial_DAO_FinancialType();
     $financialType->id = $financialTypeID;
-    if (!$financialType->find(TRUE)) {
-      CRM_Core_Error::fatal(ts("Could not find a system table"));
-    }
+    $financialType->find(TRUE);
     $tempParams['amount'] = $minimumFee;
     $tempParams['invoiceID'] = md5(uniqid(rand(), TRUE));