From 2826d587e506f2e8aab4c21cde07f1c10868579f Mon Sep 17 00:00:00 2001 From: seto Date: Thu, 19 Dec 2024 16:18:38 +0900 Subject: [PATCH] =?UTF-8?q?fix=20#4036=20=E3=80=90=E3=83=A1=E3=83=BC?= =?UTF-8?q?=E3=83=AB=E3=80=91=E9=80=81=E4=BF=A1=E6=83=85=E5=A0=B1=E3=82=92?= =?UTF-8?q?=E3=83=87=E3=83=BC=E3=82=BF=E3=83=99=E3=83=BC=E3=82=B9=E3=81=AB?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=E3=81=97=E3=81=AA=E3=81=84=E5=A0=B4=E5=90=88?= =?UTF-8?q?=E3=81=AB=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB=E3=82=92=E6=B7=BB?= =?UTF-8?q?=E4=BB=98=E3=81=99=E3=82=8B=E3=81=A8=E9=80=81=E4=BF=A1=E3=81=AB?= =?UTF-8?q?=E5=A4=B1=E6=95=97=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/Service/Front/MailFrontService.php | 17 +++++++++-------- .../bc-mail/src/Service/MailMessagesService.php | 6 +----- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/plugins/bc-mail/src/Service/Front/MailFrontService.php b/plugins/bc-mail/src/Service/Front/MailFrontService.php index d06f23dea6..ea525a350d 100644 --- a/plugins/bc-mail/src/Service/Front/MailFrontService.php +++ b/plugins/bc-mail/src/Service/Front/MailFrontService.php @@ -248,16 +248,17 @@ public function sendMail(EntityInterface $mailContent, EntityInterface $mailMess $sendEmailOptions ]); } - if ($mailContent->save_info) return; - foreach($mailFields as $field) { - if ($field->type !== 'file') continue; - // 削除フラグをセット - $mailMessage->{$field->field_name . '_delete'} = true; + if (!$mailContent->save_info) { + /** @var MailMessagesService $mailMessagesService */ + $mailMessagesService = $this->getService(MailMessagesServiceInterface::class); + $mailMessagesService->delete($mailMessage->id); } - // TODO ucmitz 未検証 - $mailMessagesTable = TableRegistry::getTableLocator()->get('BcMail.MailMessages'); - $mailMessagesTable->getFileUploader()->deleteFiles($mailMessage, $mailMessage); } catch (\Throwable $e) { + if (!$mailContent->save_info) { + /** @var MailMessagesService $mailMessagesService */ + $mailMessagesService = $this->getService(MailMessagesServiceInterface::class); + $mailMessagesService->delete($mailMessage->id); + } throw $e; } } diff --git a/plugins/bc-mail/src/Service/MailMessagesService.php b/plugins/bc-mail/src/Service/MailMessagesService.php index aaacaeeffe..e55dd7887b 100644 --- a/plugins/bc-mail/src/Service/MailMessagesService.php +++ b/plugins/bc-mail/src/Service/MailMessagesService.php @@ -143,11 +143,7 @@ public function create(EntityInterface $mailContent, $postData) $mailFieldsTable = TableRegistry::getTableLocator()->get('BcMail.MailFields'); $mailFields = $mailFieldsTable->find()->where(['MailFields.mail_content_id' => $mailContent->id, 'MailFields.use_field' => true])->all(); $this->MailMessages->convertToDb($mailFields, $entity); - if ($mailContent->save_info) { - return $this->MailMessages->saveOrFail($entity); - } else { - return $entity; - } + return $this->MailMessages->saveOrFail($entity); } throw new PersistenceFailedException($entity, __d('baser_core', '入力エラーです。内容を見直してください。')); }