Commit 2c6536b5 authored by colemanw's avatar colemanw Committed by GitHub
Browse files

Merge pull request #9784 from monishdeb/CRM-19702

CRM-19702: Fatal error when merging contact records with custom file fields
parents ad16dd2c ecdae719
......@@ -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();
CRM_Core_Error::fatal(sprintf('No record found for given file ID - %d and entity ID - %d', $fileID, $entityID));
}
$entityFileDAO->delete();
......
......@@ -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);
}
}
$dao->free();
// 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