Simplify getting contact_id from recurring contribution
authorMatthew Wire <mjw@mjwconsult.co.uk>
Mon, 10 Jan 2022 12:43:08 +0000 (12:43 +0000)
committerMatthew Wire <mjw@mjwconsult.co.uk>
Mon, 10 Jan 2022 12:43:18 +0000 (12:43 +0000)
CRM/Core/Payment.php

index 16f4691d06e630a79115ec12df758c96b221ccc1..6b599e0bf30563cdbc4ff2e789be9a8ac06dc201 100644 (file)
@@ -1745,17 +1745,7 @@ abstract class CRM_Core_Payment {
           break;
 
         case 'recur':
-          $sql = "
-    SELECT DISTINCT con.contact_id
-      FROM civicrm_contribution_recur rec
-INNER JOIN civicrm_contribution con ON ( con.contribution_recur_id = rec.id )
-     WHERE rec.id = %1";
-          $contactID = CRM_Core_DAO::singleValueQuery($sql, [
-            1 => [
-              $entityID,
-              'Integer',
-            ],
-          ]);
+          $contactID = CRM_Core_DAO::getFieldValue("CRM_Contribute_DAO_ContributionRecur", $entityID, "contact_id");
           $entityArg = 'crid';
           break;
       }