From 8bd2b329083d772e68a93ca4378ad5ad1c18ea5d Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Tue, 13 Aug 2024 16:31:50 +0300 Subject: [PATCH] prevent removal link fields --- application/Espo/Tools/FieldManager/FieldManager.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/application/Espo/Tools/FieldManager/FieldManager.php b/application/Espo/Tools/FieldManager/FieldManager.php index 9a642ff59f..3aefc5c98f 100644 --- a/application/Espo/Tools/FieldManager/FieldManager.php +++ b/application/Espo/Tools/FieldManager/FieldManager.php @@ -490,6 +490,17 @@ class FieldManager $type = $this->metadata->get(['entityDefs', $scope, 'fields', $name, 'type']); + if ( + in_array($type, [ + FieldType::LINK_MULTIPLE, + FieldType::LINK, + FieldType::LINK_ONE, + FieldType::LINK_PARENT, + ]) + ) { + throw new Error("Field type $type cannot be removed."); + } + $this->processHook('beforeRemove', $type, $scope, $name); $unsets = [