Ejegg has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/340810 )
Change subject: WIP only cry DUPLICATE if there's no change ...................................................................... WIP only cry DUPLICATE if there's no change Still need to change rest of the logic to update the contact rather than try inserting anew Bug: T159455 Change-Id: I128cb085788a8730c527af9d2a538d40ccd37410 --- M sites/all/modules/wmf_civicrm/wmf_civicrm.module 1 file changed, 25 insertions(+), 9 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/crm refs/changes/10/340810/1 diff --git a/sites/all/modules/wmf_civicrm/wmf_civicrm.module b/sites/all/modules/wmf_civicrm/wmf_civicrm.module index d887500..b31e193 100644 --- a/sites/all/modules/wmf_civicrm/wmf_civicrm.module +++ b/sites/all/modules/wmf_civicrm/wmf_civicrm.module @@ -996,21 +996,37 @@ } /** - * Throw an exception if a contribution already exists + * Throw an exception if a contribution already exists. Do not complain if there are * * @param string $gateway * @param string $gateway_txn_id * @throws WmfException */ -function wmf_civicrm_check_for_duplicates( $gateway, $gateway_txn_id ) { - $txn = wmf_civicrm_get_contributions_from_gateway_id( - $gateway, $gateway_txn_id - ); +function wmf_civicrm_check_for_duplicates( $message ) { + $query = "SELECT cntc.*, cx.*, cc.* FROM wmf_contribution_extra cx + LEFT JOIN civicrm_contribution cc ON cc.id = cx.entity_id + LEFT JOIN civicrm_contact cntc ON cc.contact_id = cntc.id + WHERE gateway = %1 AND gateway_txn_id = %2"; + + $dao = CRM_Core_DAO::executeQuery( $query, array( + 1 => array( $message['gateway'], 'String' ), + 2 => array( $message['gateway_txn_id'], 'String' ), + ) ); + $txn = wmf_civicrm_dao_to_list( $dao ); if ( $txn ) { - throw new WmfException( - 'DUPLICATE_CONTRIBUTION', - 'Contribution already exists. Ignoring message.' - ); + $changed = false; + $checkFields = array( 'first_name', 'last_name' ); + foreach( $checkFields as $field ) { + if ( $txn[$field] !== $message[$field] ) { + $changed = true; + } + } + if ( !$changed ) { + throw new WmfException( + 'DUPLICATE_CONTRIBUTION', + 'Contribution already exists. Ignoring message.' + ); + } } } -- To view, visit https://gerrit.wikimedia.org/r/340810 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I128cb085788a8730c527af9d2a538d40ccd37410 Gerrit-PatchSet: 1 Gerrit-Project: wikimedia/fundraising/crm Gerrit-Branch: master Gerrit-Owner: Ejegg <eeggles...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits