dev/core#562 Remove more DAO->free() calls
[civicrm-core.git] / CRM / Dedupe / Merger.php
index 5d9921bcb1e4a4c13fd849dfa3afa472594dd695..869454b0ca23b997f1fa0d538fbff87713fb74c5 100644 (file)
@@ -468,11 +468,11 @@ INNER JOIN  civicrm_membership membership2 ON membership1.membership_type_id = m
       $membershipIDs = CRM_Utils_Array::collect('id',
         CRM_Utils_Array::value('values',
           civicrm_api3("Membership", "get", [
-              "contact_id" => $otherID,
-              "return" => "id",
-            ]
-          )
-        ));
+            "contact_id" => $otherID,
+            "return" => "id",
+          ])
+        )
+      );
 
       if (!empty($membershipIDs)) {
         civicrm_api3("Membership", "get", [
@@ -816,15 +816,15 @@ INNER JOIN  civicrm_membership membership2 ON membership1.membership_type_id = m
     $msg = '';
     if (!empty($stats['merged'])) {
       $msg = '<p>' . ts('One contact merged.', [
-          'count' => $stats['merged'],
-          'plural' => '%count contacts merged.',
-        ]) . '</p>';
+        'count' => $stats['merged'],
+        'plural' => '%count contacts merged.',
+      ]) . '</p>';
     }
     if (!empty($stats['skipped'])) {
       $msg .= '<p>' . ts('One contact was skipped.', [
-          'count' => $stats['skipped'],
-          'plural' => '%count contacts were skipped.',
-        ]) . '</p>';
+        'count' => $stats['skipped'],
+        'plural' => '%count contacts were skipped.',
+      ]) . '</p>';
     }
     return $msg;
   }
@@ -1038,7 +1038,7 @@ INNER JOIN  civicrm_membership membership2 ON membership1.membership_type_id = m
    *
    * @return bool
    */
-  static public function locationIsSame($mainAddress, $comparisonAddress) {
+  public static function locationIsSame($mainAddress, $comparisonAddress) {
     $keysToIgnore = [
       'id',
       'is_primary',
@@ -1326,6 +1326,7 @@ INNER JOIN  civicrm_membership membership2 ON membership1.membership_type_id = m
                 // Set this value as the default against the 'other' contact value
                 $rows["move_location_{$blockName}_{$count}"]['main'] = $mainValueCheck[$blockInfo['displayField']];
                 $rows["move_location_{$blockName}_{$count}"]['main_is_primary'] = $mainValueCheck['is_primary'];
+                $rows["move_location_{$blockName}_{$count}"]['location_entity'] = $blockName;
                 $mainContactBlockId = $mainValueCheck['id'];
                 break;
               }
@@ -1829,7 +1830,6 @@ INNER JOIN  civicrm_membership membership2 ON membership1.membership_type_id = m
           CRM_Core_BAO_File::deleteFileReferences($fileIds[$mainId], $mainId, $customId);
         }
       }
-      $dao->free();
 
       // move the other contact's file to main contact
       //NYSS need to INSERT or UPDATE depending on whether main contact has an existing record
@@ -2035,7 +2035,7 @@ INNER JOIN  civicrm_membership membership2 ON membership1.membership_type_id = m
     ];
     $activity = civicrm_api3('activity', 'create', [
       'source_contact_id' => CRM_Core_Session::getLoggedInContactID() ? CRM_Core_Session::getLoggedInContactID() :
-        $mainId,
+      $mainId,
       'subject' => ts('Contact ID %1 has been merged and deleted.', $params),
       'target_contact_id' => $mainId,
       'activity_type_id' => 'Contact Merged',
@@ -2047,7 +2047,7 @@ INNER JOIN  civicrm_membership membership2 ON membership1.membership_type_id = m
     ])) {
       civicrm_api3('activity', 'create', [
         'source_contact_id' => CRM_Core_Session::getLoggedInContactID() ? CRM_Core_Session::getLoggedInContactID() :
-          $otherId,
+        $otherId,
         'subject' => ts('Contact ID %1 has been merged into Contact ID %2 and deleted.', $params),
         'target_contact_id' => $otherId,
         'activity_type_id' => 'Contact Deleted by Merge',
@@ -2079,7 +2079,7 @@ INNER JOIN  civicrm_membership membership2 ON membership1.membership_type_id = m
    *   Limit to searching for matches against this many contacts.
    *
    * @return array
-   *    Array of matches meeting the criteria.
+   *   Array of matches meeting the criteria.
    */
   public static function getDuplicatePairs($rule_group_id, $group_id, $reloadCacheIfEmpty, $batchLimit, $isSelected, $orderByClause = '', $includeConflicts = TRUE, $criteria = [], $checkPermissions = TRUE, $searchLimit = 0) {
     $where = self::getWhereString($isSelected);