Ejegg has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/305577

Change subject: Check for duplicates before re-queueing MISSING_PREDECESSOR
......................................................................

Check for duplicates before re-queueing MISSING_PREDECESSOR

When we've got a missing pending db entry, don't re-queue the donation
if it's already been added to Civi.

Bug: T122641
Change-Id: Ic3c21cef7245de0e8b48cbc900ba1381549e0064
---
M sites/all/modules/queue2civicrm/queue2civicrm.module
1 file changed, 10 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/crm 
refs/changes/77/305577/1

diff --git a/sites/all/modules/queue2civicrm/queue2civicrm.module 
b/sites/all/modules/queue2civicrm/queue2civicrm.module
index c2eec3b..67f8337 100644
--- a/sites/all/modules/queue2civicrm/queue2civicrm.module
+++ b/sites/all/modules/queue2civicrm/queue2civicrm.module
@@ -262,6 +262,16 @@
     if ( isset( $msg['completion_message_id'] ) ) {
         $dbEntry = queue2civicrm_update_from_pending_db( $msg );
         if ( !$dbEntry ) {
+            // If the contribution has already been imported, we don't want
+            // to re-queue this message, but drop it entirely.
+            if ( wmf_civicrm_get_contributions_from_gateway_id(
+                $msg['gateway'], $msg['gateway_txn_id']
+            ) ) {
+                throw new WmfException(
+                    'DUPLICATE_CONTRIBUTION',
+                    'Contribution already exists. Ignoring message.'
+                );
+            }
             // If the pending db row is missing, throw an exception that
             // tells dequeue_loop to requeue the incomplete message with a 
delay
             $errorMessage = "Message 
{$msg['gateway']}-{$msg['gateway_txn_id']} " .

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic3c21cef7245de0e8b48cbc900ba1381549e0064
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

Reply via email to