Skip to content

Commit 70ecb18

Browse files
6543silverwind
authored andcommitted
Dont load Review if Comment is CommentTypeReviewRequest (go-gitea#28551)
RequestReview get deleted on review. So we don't have to try to load them on comments. broken out go-gitea#28544
1 parent de2add3 commit 70ecb18

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

models/issues/comment.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,8 +695,15 @@ func (c *Comment) LoadReactions(ctx context.Context, repo *repo_model.Repository
695695
}
696696

697697
func (c *Comment) loadReview(ctx context.Context) (err error) {
698+
if c.ReviewID == 0 {
699+
return nil
700+
}
698701
if c.Review == nil {
699702
if c.Review, err = GetReviewByID(ctx, c.ReviewID); err != nil {
703+
// review request which has been replaced by actual reviews doesn't exist in database anymore, so ignorem them.
704+
if c.Type == CommentTypeReviewRequest {
705+
return nil
706+
}
700707
return err
701708
}
702709
}

models/issues/comment_list.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,8 @@ func (comments CommentList) loadReviews(ctx context.Context) error {
430430
for _, comment := range comments {
431431
comment.Review = reviews[comment.ReviewID]
432432
if comment.Review == nil {
433-
if comment.ReviewID > 0 {
433+
// review request which has been replaced by actual reviews doesn't exist in database anymore, so don't log errors for them.
434+
if comment.ReviewID > 0 && comment.Type != CommentTypeReviewRequest {
434435
log.Error("comment with review id [%d] but has no review record", comment.ReviewID)
435436
}
436437
continue

models/issues/review.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,9 @@ func AddReviewRequest(ctx context.Context, issue *Issue, reviewer, doer *user_mo
621621
return nil, err
622622
}
623623

624+
// func caller use the created comment to retrieve created review too.
625+
comment.Review = review
626+
624627
return comment, committer.Commit()
625628
}
626629

0 commit comments

Comments
 (0)