@@ -10,6 +10,7 @@ import (
1010 repo_model "code.gitea.io/gitea/models/repo"
1111 user_model "code.gitea.io/gitea/models/user"
1212 "code.gitea.io/gitea/modules/container"
13+ "code.gitea.io/gitea/modules/log"
1314)
1415
1516// CommentList defines a list of comments
@@ -422,37 +423,18 @@ func (comments CommentList) loadReviews(ctx context.Context) error {
422423
423424 reviewIDs := comments .getReviewIDs ()
424425 reviews := make (map [int64 ]* Review , len (reviewIDs ))
425- left := len (reviewIDs )
426- for left > 0 {
427- limit := db .DefaultMaxInSize
428- if left < limit {
429- limit = left
430- }
431- rows , err := db .GetEngine (ctx ).
432- In ("id" , reviewIDs [:limit ]).
433- Rows (new (Review ))
434- if err != nil {
435- return err
436- }
437-
438- for rows .Next () {
439- var review Review
440- err = rows .Scan (& review )
441- if err != nil {
442- _ = rows .Close ()
443- return err
444- }
445-
446- reviews [review .ID ] = & review
447- }
448- _ = rows .Close ()
449-
450- left -= limit
451- reviewIDs = reviewIDs [limit :]
426+ if err := db .GetEngine (ctx ).In ("id" , reviewIDs ).Find (& reviews ); err != nil {
427+ return err
452428 }
453429
454430 for _ , comment := range comments {
455431 comment .Review = reviews [comment .ReviewID ]
432+ if comment .Review == nil {
433+ if comment .ReviewID > 0 {
434+ log .Error ("comment with review id [%d] but has no review record" , comment .ReviewID )
435+ }
436+ continue
437+ }
456438
457439 // If the comment dismisses a review, we need to load the reviewer to show whose review has been dismissed.
458440 // Otherwise, the reviewer is the poster of the comment, so we don't need to load it.
0 commit comments