Merge pull request #20119 from civicrm/5.37
[civicrm-core.git] / CRM / Core / BAO / CustomField.php
index b27bad0c39b37a8b71f9d7d2864dfe338edb3c63..ab42c14cc520755a183589a5e3a35e9d83d7585f 100644 (file)
@@ -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'];
@@ -1994,6 +2001,11 @@ WHERE  id IN ( %1, %2 )
       }
     }
 
+    // Remove option group IDs from fields changed to Text html_type.
+    if ($htmlType == 'Text') {
+      $params['option_group_id'] = '';
+    }
+
     // check for orphan option groups
     if (!empty($params['option_group_id'])) {
       if (!empty($params['id'])) {