From 14b74ca63305b13e0f53c85f6011e3bdd32c9988 Mon Sep 17 00:00:00 2001 From: monishdeb Date: Tue, 16 Jun 2015 12:49:39 +0530 Subject: [PATCH] CRM-16611 fix - Fatal error on batch processing membership when Payment status = Pending https://issues.civicrm.org/jira/browse/CRM-16611 --- CRM/Contribute/BAO/Contribution.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index 062d8ab24f..a4ab84a2a4 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -2736,7 +2736,7 @@ WHERE contribution_id = %1 "; if (!empty($params['payment_processor'])) { $balanceTrxnParams['payment_processor_id'] = $params['payment_processor']; } - CRM_Core_BAO_FinancialTrxn::create($balanceTrxnParams); + $financialTxn = CRM_Core_BAO_FinancialTrxn::create($balanceTrxnParams); } } @@ -2927,8 +2927,9 @@ WHERE contribution_id = %1 "; CRM_Price_BAO_LineItem::processPriceSet($entityId, CRM_Utils_Array::value('line_item', $params), $params['contribution'], $entityTable, $update); } - // create batch entry if batch_id is passed - if (!empty($params['batch_id'])) { + // create batch entry if batch_id is passed and + // ensure no batch entry is been made on 'Pending' or 'Failed' contribution, CRM-16611 + if (!empty($params['batch_id']) && !empty($financialTxn)) { $entityParams = array( 'batch_id' => $params['batch_id'], 'entity_table' => 'civicrm_financial_trxn', -- 2.25.1