Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #4036 【メール】送信情報をデータベースに保存しない場合にファイルを添付すると送信に失敗する #4093

Merged
merged 1 commit into from
Dec 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions plugins/bc-mail/src/Service/Front/MailFrontService.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,18 +248,19 @@ 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;
}
// 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;
}
if (!$mailContent->save_info) {
/** @var MailMessagesService $mailMessagesService */
$mailMessagesService = $this->getService(MailMessagesServiceInterface::class);
$mailMessagesService->delete($mailMessage->id);
}
}

/**
Expand Down
6 changes: 1 addition & 5 deletions plugins/bc-mail/src/Service/MailMessagesService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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', '入力エラーです。内容を見直してください。'));
}
Expand Down