Skip to content

Commit

Permalink
Merge pull request #9424 from nextcloud/fix/db/dirty-read-local-messa…
Browse files Browse the repository at this point in the history
…ge-update

fix(db): Avoid dirty read for local message updates
  • Loading branch information
ChristophWurst authored Mar 5, 2024
2 parents 9a7e782 + fff840a commit 6827296
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions lib/Db/LocalMessageMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,14 +256,14 @@ public function updateWithRecipients(LocalMessage $message, array $to, array $cc
$message = $this->update($message);

$this->recipientMapper->updateRecipients($message->getId(), $message->getRecipients(), $to, $cc, $bcc);
$recipients = $this->recipientMapper->findByLocalMessageId($message->getId());
$message->setRecipients($recipients);
$this->db->commit();
return $message;
} catch (Throwable $e) {
$this->db->rollBack();
throw $e;
}
$recipients = $this->recipientMapper->findByLocalMessageId($message->getId());
$message->setRecipients($recipients);
return $message;
}

public function deleteWithRecipients(LocalMessage $message): void {
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Db/LocalMessageMapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public function testSaveWithRecipient(): void {
$this->assertCount(1, $row->getRecipients());
}

public function testUpdateWithRecipient(): void {
public function testUpdateWithRecipients(): void {
$results = $this->mapper->getAllForUser($this->account->getUserId());
$this->assertEmpty($results[0]->getRecipients());
// cleanup
Expand Down

0 comments on commit 6827296

Please sign in to comment.