Backport #28551
RequestReview get deleted on review.
So we don't have to try to load them on comments.
}
func (c *Comment) loadReview(ctx context.Context) (err error) {
+ if c.ReviewID == 0 {
+ return nil
+ }
if c.Review == nil {
if c.Review, err = GetReviewByID(ctx, c.ReviewID); err != nil {
+ // review request which has been replaced by actual reviews doesn't exist in database anymore, so ignorem them.
+ if c.Type == CommentTypeReviewRequest {
+ return nil
+ }
return err
}
}
for _, comment := range comments {
comment.Review = reviews[comment.ReviewID]
if comment.Review == nil {
- if comment.ReviewID > 0 {
+ // review request which has been replaced by actual reviews doesn't exist in database anymore, so don't log errors for them.
+ if comment.ReviewID > 0 && comment.Type != CommentTypeReviewRequest {
log.Error("comment with review id [%d] but has no review record", comment.ReviewID)
}
continue
return nil, err
}
+ // func caller use the created comment to retrieve created review too.
+ comment.Review = review
+
return comment, committer.Commit()
}