Wrap PdfSignedMessage handling in a transaction

Ensure atomicity when writing stored objects and marking signatures as signed by wrapping these operations in a database transaction. This reduces the risk of partial updates and improves data consistency.
This commit is contained in:
2024-12-16 15:44:40 +01:00
parent d56d00421a
commit 82fb98348b
2 changed files with 9 additions and 3 deletions

View File

@@ -51,11 +51,12 @@ final readonly class PdfSignedMessageHandler implements MessageHandlerInterface
throw new \RuntimeException('no stored object found');
}
$this->storedObjectManager->write($storedObject, $message->content);
$this->entityManager->wrapInTransaction(function () use ($storedObject, $message, $signature) {
$this->storedObjectManager->write($storedObject, $message->content);
$this->signatureStepStateChanger->markSignatureAsSigned($signature, $message->signatureZoneIndex);
$this->signatureStepStateChanger->markSignatureAsSigned($signature, $message->signatureZoneIndex);
});
$this->entityManager->flush();
$this->entityManager->clear();
}
}