Skip to content

Commit

Permalink
fix #2842 php8の環境において、コンテンツ一覧画面でメールフォーム複製時にエラーが表示される
Browse files Browse the repository at this point in the history
  • Loading branch information
fuchigam1 committed Nov 6, 2023
1 parent 228d33c commit 1ce5cfc
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions lib/Baser/Plugin/Mail/Model/MailContent.php
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,11 @@ public function copy($id, $newParentId, $newTitle, $newAuthorId, $newSiteId = nu
$data['Content']['site_id'] = $newSiteId;
$data['Content']['parent_id'] = $this->Content->copyContentFolderPath($url, $newSiteId);
}
$this->getDataSource()->begin();
$db = $this->getDataSource();
$transactionBegun = false;
if ($db->nestedTransactionSupported()) {
$transactionBegun = $db->begin();
}
if ($result = $this->save($data)) {
$result['MailContent']['id'] = $this->id;
$data = $result;
Expand Down Expand Up @@ -331,10 +335,14 @@ public function copy($id, $newParentId, $newTitle, $newAuthorId, $newSiteId = nu
'oldData' => $oldData,
]);

$this->getDataSource()->commit();
if ($transactionBegun) {
$db->commit();
}
return $result;
}
$this->getDataSource()->rollback();
if ($transactionBegun) {
$db->rollback();
}
return false;
}

Expand Down

0 comments on commit 1ce5cfc

Please sign in to comment.