From 21474845019222d3fc45531292ccf150db6aa1f7 Mon Sep 17 00:00:00 2001 From: Peter Burian Date: Fri, 15 Nov 2024 07:45:08 +0000 Subject: [PATCH] Refactor low-level transactions to `DatabaseTransaction/Repository->transaction()` API to handle nested transactions - Important: It is recommended to update transactions to use new `DatabaseTransaction` API to ensure correct transaction handling within nested transactions. - Introduced new `DatabaseTransaction` API usable directly via DI or via `Repository->getTransaction()` remp/crm#3330 --- src/Repositories/InvoicesRepository.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Repositories/InvoicesRepository.php b/src/Repositories/InvoicesRepository.php index e6eac60..5104962 100644 --- a/src/Repositories/InvoicesRepository.php +++ b/src/Repositories/InvoicesRepository.php @@ -123,7 +123,7 @@ final public function updateItems(ActiveRow $invoice): void { $payment = $invoice->related('payments')->fetch(); - $this->getDatabase()->transaction(function () use ($invoice, $payment) { + $this->getTransaction()->wrap(function () use ($invoice, $payment) { $this->invoiceItemsRepository->getTable()->where([ 'invoice_id' => $invoice->id, ])->delete();