Skip to content

Commit

Permalink
Fix attached document deletion when deleting a page tree node
Browse files Browse the repository at this point in the history
Backport of #1737 into v4.
  • Loading branch information
johnnyomair committed Feb 22, 2024
1 parent fdc7468 commit 6af7d16
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/clever-guests-sleep.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@comet/cms-api": patch
---

Fix attached document deletion when deleting a page tree node
3 changes: 2 additions & 1 deletion packages/api/cms-api/src/page-tree/page-tree.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,8 @@ export class PageTreeService {
if (attachedDocument.id) {
try {
const repository = this.em.getRepository(attachedDocument.type);
await repository.removeAndFlush(attachedDocument);
const document = await repository.findOneOrFail(attachedDocument.documentId);
await repository.removeAndFlush(document);
await this.attachedDocumentsRepository.removeAndFlush(attachedDocument);
} catch {
throw new Error(`documentType ${attachedDocument.type} and documentId ${attachedDocument.id} cannot resolve`);
Expand Down

0 comments on commit 6af7d16

Please sign in to comment.