Commit ecdae719 authored by Monish Deb's avatar Monish Deb Committed by deb.monish
Browse files

CRM-19702: Fatal error when merging contact records with custom file fields

parent 12608054
......@@ -203,7 +203,7 @@ class CRM_Core_BAO_File extends CRM_Core_DAO_File {
$entityFileDAO->entity_table = $tableName;
if (!$entityFileDAO->find(TRUE)) {
CRM_Core_Error::fatal(sprintf('No record found for given file ID - %d and entity ID - %d', $fileID, $entityID));
......@@ -1644,14 +1644,12 @@ INNER JOIN civicrm_membership membership2 ON membership1.membership_type_id = m
$dao = CRM_Core_DAO::executeQuery($sql);
while ($dao->fetch()) {
$fileIds[$dao->entity_id] = $dao->file_id;
if ($dao->entity_id == $mainId) {
CRM_Core_BAO_File::deleteFileReferences($fileIds[$mainId], $mainId, $customId);
// delete the main contact's file
if (!empty($fileIds[$mainId])) {
CRM_Core_BAO_File::deleteFileReferences($fileIds[$mainId], $mainId, $customId);
// move the other contact's file to main contact
//NYSS need to INSERT or UPDATE depending on whether main contact has an existing record
if (CRM_Core_DAO::singleValueQuery("SELECT id FROM {$tableName} WHERE entity_id = {$mainId}")) {
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment