Skip to content

Commit

Permalink
fix baserproject#4036 【メール】送信情報をデータベースに保存しない場合にファイルを添付すると送信に失敗する
Browse files Browse the repository at this point in the history
  • Loading branch information
seto1 committed Dec 19, 2024
1 parent 64602c7 commit 2db4811
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
11 changes: 3 additions & 8 deletions plugins/bc-mail/src/Service/Front/MailFrontService.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,14 +249,9 @@ public function sendMail(EntityInterface $mailContent, EntityInterface $mailMess
]);
}
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);
/** @var MailMessagesService $mailMessagesService */
$mailMessagesService = $this->getService(MailMessagesServiceInterface::class);
$mailMessagesService->delete($mailMessage->id);
} catch (\Throwable $e) {
throw $e;
}
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

0 comments on commit 2db4811

Please sign in to comment.