Merge pull request #17020 from eileenmcnaughton/dedupe1
[civicrm-core.git] / CRM / Dedupe / Finder.php
index f2626bcb328ed8eebeb8cf7edf87d3552b90426b..97e8abcf51bc6aabd98ad945e0cb2b57a8a55ab3 100644 (file)
@@ -230,7 +230,7 @@ class CRM_Dedupe_Finder {
         continue;
       }
       foreach ($cg['fields'] as $cf) {
-        $flat[$cf['column_name']] = CRM_Utils_Array::value('data', $cf['customValue']);
+        $flat[$cf['column_name']] = $cf['customValue']['data'] ?? NULL;
       }
     }
 
@@ -340,16 +340,22 @@ class CRM_Dedupe_Finder {
       }
 
       $mainContacts[] = $row = [
-        'dstID' => $dstID,
+        'dstID' => (int) $dstID,
         'dstName' => $displayNames[$dstID],
-        'srcID' => $srcID,
+        'srcID' => (int) $srcID,
         'srcName' => $displayNames[$srcID],
         'weight' => $dupes[2],
         'canMerge' => TRUE,
       ];
 
-      $data = CRM_Core_DAO::escapeString(serialize($row));
-      CRM_Core_BAO_PrevNextCache::setItem('civicrm_contact', $dstID, $srcID, $cacheKeyString, $data);
+      CRM_Core_DAO::executeQuery("INSERT INTO civicrm_prevnext_cache (entity_table, entity_id1, entity_id2, cacheKey, data) VALUES
+        ('civicrm_contact', %1, %2, %3, %4)", [
+          1 => [$dstID, 'Integer'],
+          2 => [$srcID, 'Integer'],
+          3 => [$cacheKeyString, 'String'],
+          4 => [serialize($row), 'String'],
+        ]
+      );
     }
     return $mainContacts;
   }