From f0237005c04daca0cc206909db26f9064a72ef66 Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Fri, 5 Nov 2021 12:14:56 +0200 Subject: [PATCH] fixes --- application/Espo/Core/Record/Service.php | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/application/Espo/Core/Record/Service.php b/application/Espo/Core/Record/Service.php index 0ca68d6e7d..b12d4433b9 100644 --- a/application/Espo/Core/Record/Service.php +++ b/application/Espo/Core/Record/Service.php @@ -245,12 +245,10 @@ class Service implements Crud, $historyRecord->set('ipAddress', $this->user->get('ipAddress')); $historyRecord->set('authLogRecordId', $this->user->get('authLogRecordId')); - if ($entity) { - $historyRecord->set([ - 'targetType' => $entity->getEntityType(), - 'targetId' => $entity->getId() - ]); - } + $historyRecord->set([ + 'targetType' => $entity->getEntityType(), + 'targetId' => $entity->getId() + ]); $this->entityManager->saveEntity($historyRecord); } @@ -1576,9 +1574,7 @@ class Service implements Crud, $idAttribute = $field . 'Id'; - if ($attachment) { - $attributes->$idAttribute = $attachment->getId(); - } + $attributes->$idAttribute = $attachment->getId(); } } else if (in_array($type, ['attachmentMultiple'])) { @@ -1593,18 +1589,16 @@ class Service implements Crud, $attachmentRepository = $this->entityManager->getRepository('Attachment'); foreach ($attachmentList as $attachment) { - $attachment = $$attachmentRepository->getCopiedAttachment($attachment); + $attachment = $attachmentRepository->getCopiedAttachment($attachment); $attachment->set('field', $field); $this->entityManager->saveEntity($attachment); - if ($attachment) { - $idList[] = $attachment->getId(); + $idList[] = $attachment->getId(); - $nameHash->{$attachment->getId()} = $attachment->get('name'); - $typeHash->{$attachment->getId()} = $attachment->get('type'); - } + $nameHash->{$attachment->getId()} = $attachment->get('name'); + $typeHash->{$attachment->getId()} = $attachment->get('type'); } $attributes->{$field . 'Ids'} = $idList;