From 1b8b0c1137af36252929b7d0a2ca8b0d7a096f12 Mon Sep 17 00:00:00 2001 From: Mathieu Lutfy Date: Wed, 24 Mar 2021 17:06:27 -0400 Subject: [PATCH] File CustomField: avoid renaming an empty file --- CRM/Core/BAO/CustomField.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CRM/Core/BAO/CustomField.php b/CRM/Core/BAO/CustomField.php index f45707ca96..ab42c14cc5 100644 --- a/CRM/Core/BAO/CustomField.php +++ b/CRM/Core/BAO/CustomField.php @@ -1551,6 +1551,13 @@ SELECT id $mimeType = $fileDAO->mime_type; } } + elseif (empty($value['name'])) { + // Happens when calling the API to update custom fields values, but the filename + // is empty, for an existing entity (in a specific case, was from a d7-webform + // that was updating a relationship with a File customfield, so $value['id'] was + // not empty, but the filename was empty. + return; + } else { $fName = $value['name']; $mimeType = $value['type']; -- 2.25.1