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:
Julien Fastré 2024-12-16 15:44:40 +01:00
parent d56d00421a
commit 82fb98348b
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB
2 changed files with 9 additions and 3 deletions

View File

@ -0,0 +1,5 @@
kind: Fixed
body: Wrap handling of PdfSignedMessage into transactions
time: 2024-12-16T15:38:50.974937062+01:00
custom:
Issue: ""

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();
}
}