CRM-14800 fix - Contact merge deletes a contribution record if it is linked to a...
authorCiviCRM <info@civicrm.org>
Fri, 6 Jun 2014 13:44:12 +0000 (19:14 +0530)
committerCiviCRM <info@civicrm.org>
Fri, 6 Jun 2014 13:44:12 +0000 (19:14 +0530)
https://issues.civicrm.org/jira/browse/CRM-14800

CRM/Dedupe/Merger.php

index ef3a6261a78d5a516ceadfd1c7aa1a22aab70408..4bd23f7115efb985b754ea6655dbe709b1404e47 100644 (file)
@@ -459,11 +459,13 @@ INNER JOIN  civicrm_membership membership2 ON membership1.membership_type_id = m
         foreach ($cidRefs[$table] as $field) {
           // carry related contributions CRM-5359
           if (in_array($table, $paymentTables)) {
-            $payOprSqls = self::operationSql($mainId, $otherId, $table, $tableOperations, 'payment');
-            $sqls = array_merge($sqls, $payOprSqls);
-
             $paymentSqls = self::paymentSql($table, $mainId, $otherId);
             $sqls = array_merge($sqls, $paymentSqls);
+
+            if (!empty($tables) && !in_array('civicrm_contribution', $tables)) {
+              $payOprSqls = self::operationSql($mainId, $otherId, $table, $tableOperations, 'payment');
+              $sqls = array_merge($sqls, $payOprSqls);
+            }
           }
 
           $preOperationSqls = self::operationSql($mainId, $otherId, $table, $tableOperations);