EspoCRM – Open Source CRM Application
PHP calendarcontactscrmcrm-platformcrm-systemcustomer-portalcustomer-supportcustomizabledocumentsemail-marketingkanbanleadsopen-sourcephpplatformsales-automationsingle-page-applicationsupport
Mass update processor attachment handling ref
Yurii5be3e7ef2a01
diff --git a/application/Espo/Tools/MassUpdate/Processor.php b/application/Espo/Tools/MassUpdate/Processor.phpindex 22c5e69662..3a8f608fe4 100644--- a/application/Espo/Tools/MassUpdate/Processor.php+++ b/application/Espo/Tools/MassUpdate/Processor.php@@ -166,7 +166,7 @@ class ProcessorData $data,int $i,array $fieldToCopyList,- Service $service+ Service $service,): bool {$service->loadAdditionalFields($entity);@@ -175,7 +175,16 @@ class Processorreturn false;}- $values = $this->prepareItemValueMap($entity, $data, $i, $fieldToCopyList);+ try {+ $values = $this->prepareItemValueMap($entity, $data, $i, $fieldToCopyList);+ } catch (Forbidden $e) {+ $this->log->notice("Mass update forbidden. Record: {id}.", [+ 'exception' => $e,+ 'id' => $entity->getId(),+ ]);++ return false;+ }$service->filterInputReadOnlySaved($entity, $values);@@ -223,6 +232,7 @@ class Processor/*** @param string[] $copyFieldList+ * @throws Forbidden*/private function prepareItemValueMap(Entity $entity, Data $data, int $i, array $copyFieldList): stdClass{@@ -235,6 +245,7 @@ class Processor/*** @param string[] $copyFieldList+ * @throws Forbidden*/private function copy(string $entityType, Data $data, int $i, array $copyFieldList): Data{@@ -265,6 +276,9 @@ class Processorreturn $data;}+ /**+ * @throws Forbidden+ */private function copyFileField(string $field, Data $data): Data{$attribute = $field . 'Id';@@ -281,6 +295,10 @@ class Processorreturn $data->with($attribute, null);}+ if (!$this->acl->checkEntityRead($attachment)) {+ throw new Forbidden("No access to attachment $id.");+ }+/** @var AttachmentRepository $attachmentRepository */$attachmentRepository = $this->entityManager->getRepository(Attachment::ENTITY_TYPE);@@ -289,6 +307,9 @@ class Processorreturn $data->with($attribute, $copiedAttachment->getId());}+ /**+ * @throws Forbidden+ */private function copyAttachmentMultipleField(string $field, Data $data): Data{$attribute = $field . 'Ids';@@ -315,6 +336,10 @@ class Processorcontinue;}+ if (!$this->acl->checkEntityRead($attachment)) {+ throw new Forbidden("No access to attachment $id.");+ }+$copiedIds[] = $attachmentRepository->getCopiedAttachment($attachment)->getId();