diff --git a/lib/Baser/Plugin/Mail/Model/MailContent.php b/lib/Baser/Plugin/Mail/Model/MailContent.php index b46b952d4c..51fcf09c78 100755 --- a/lib/Baser/Plugin/Mail/Model/MailContent.php +++ b/lib/Baser/Plugin/Mail/Model/MailContent.php @@ -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; @@ -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; }