[Backport] Fix comment broken issue ref dependence (#12651) (#12692)

* deleteIssuesByRepoID: delete related CommentTypeRemoveDependency & CommentTypeAddDependency comments too

* Ignore ErrIssueNotExist on comment.LoadDepIssueDetails()

* CI.restart()
This commit is contained in:
6543 2020-09-03 11:23:36 +02:00 committed by GitHub
parent 69e4b6910b
commit 0fa538e552
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View file

@ -1953,6 +1953,11 @@ func deleteIssuesByRepoID(sess Engine, repoID int64) (attachmentPaths []string,
return return
} }
if _, err = sess.In("dependent_issue_id", deleteCond).
Delete(&Comment{}); err != nil {
return
}
var attachments []*Attachment var attachments []*Attachment
if err = sess.In("issue_id", deleteCond). if err = sess.In("issue_id", deleteCond).
Find(&attachments); err != nil { Find(&attachments); err != nil {

View file

@ -969,8 +969,10 @@ func ViewIssue(ctx *context.Context) {
} }
} else if comment.Type == models.CommentTypeRemoveDependency || comment.Type == models.CommentTypeAddDependency { } else if comment.Type == models.CommentTypeRemoveDependency || comment.Type == models.CommentTypeAddDependency {
if err = comment.LoadDepIssueDetails(); err != nil { if err = comment.LoadDepIssueDetails(); err != nil {
ctx.ServerError("LoadDepIssueDetails", err) if !models.IsErrIssueNotExist(err) {
return ctx.ServerError("LoadDepIssueDetails", err)
return
}
} }
} else if comment.Type == models.CommentTypeCode || comment.Type == models.CommentTypeReview { } else if comment.Type == models.CommentTypeCode || comment.Type == models.CommentTypeReview {
comment.RenderedContent = string(markdown.Render([]byte(comment.Content), ctx.Repo.RepoLink, comment.RenderedContent = string(markdown.Render([]byte(comment.Content), ctx.Repo.RepoLink,