From dcf2c29c2202e52eb33547f5c5e8c869df0a0a87 Mon Sep 17 00:00:00 2001 From: "Otto Richter (fnetX)" Date: Thu, 17 Mar 2022 23:04:09 +0100 Subject: [PATCH] Delete related notifications on issue deletion too (#18953) * use .Decr for issue comment counting * Remove notification on issue removal --- models/issue.go | 1 + models/issue_comment.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/models/issue.go b/models/issue.go index ed94195ed1e6a..53ee585dc00e9 100644 --- a/models/issue.go +++ b/models/issue.go @@ -2124,6 +2124,7 @@ func deleteIssue(ctx context.Context, issue *Issue) error { &IssueDependency{}, &IssueAssignees{}, &IssueUser{}, + &Notification{}, &Reaction{}, &IssueWatch{}, &Stopwatch{}, diff --git a/models/issue_comment.go b/models/issue_comment.go index 0af45e80e8b3a..8390d90f8a688 100644 --- a/models/issue_comment.go +++ b/models/issue_comment.go @@ -1163,7 +1163,7 @@ func deleteComment(e db.Engine, comment *Comment) error { } if comment.Type == CommentTypeComment { - if _, err := e.Exec("UPDATE `issue` SET num_comments = num_comments - 1 WHERE id = ?", comment.IssueID); err != nil { + if _, err := e.ID(comment.IssueID).Decr("num_comments").Update(new(Issue)); err != nil { return err } }