Skip to content

Commit c363bd0

Browse files
authored
Strict pagination check (#32548)
1 parent 633785a commit c363bd0

9 files changed

+11
-11
lines changed

models/issues/comment.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1108,7 +1108,7 @@ func FindComments(ctx context.Context, opts *FindCommentsOptions) (CommentList,
11081108
sess.Join("INNER", "issue", "issue.id = comment.issue_id")
11091109
}
11101110

1111-
if opts.Page != 0 {
1111+
if opts.Page > 0 {
11121112
sess = db.SetSessionPagination(sess, opts)
11131113
}
11141114

models/issues/issue.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ func (issue *Issue) BlockedByDependencies(ctx context.Context, opts db.ListOptio
641641
Where("issue_id = ?", issue.ID).
642642
// sort by repo id then created date, with the issues of the same repo at the beginning of the list
643643
OrderBy("CASE WHEN issue.repo_id = ? THEN 0 ELSE issue.repo_id END, issue.created_unix DESC", issue.RepoID)
644-
if opts.Page != 0 {
644+
if opts.Page > 0 {
645645
sess = db.SetSessionPagination(sess, &opts)
646646
}
647647
err = sess.Find(&issueDeps)

models/issues/issue_watch.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func GetIssueWatchers(ctx context.Context, issueID int64, listOptions db.ListOpt
105105
And("`user`.prohibit_login = ?", false).
106106
Join("INNER", "`user`", "`user`.id = `issue_watch`.user_id")
107107

108-
if listOptions.Page != 0 {
108+
if listOptions.Page > 0 {
109109
sess = db.SetSessionPagination(sess, &listOptions)
110110
watches := make([]*IssueWatch, 0, listOptions.PageSize)
111111
return watches, sess.Find(&watches)

models/issues/label.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ func GetLabelsByRepoID(ctx context.Context, repoID int64, sortType string, listO
390390
sess.Asc("name")
391391
}
392392

393-
if listOptions.Page != 0 {
393+
if listOptions.Page > 0 {
394394
sess = db.SetSessionPagination(sess, &listOptions)
395395
}
396396

@@ -462,7 +462,7 @@ func GetLabelsByOrgID(ctx context.Context, orgID int64, sortType string, listOpt
462462
sess.Asc("name")
463463
}
464464

465-
if listOptions.Page != 0 {
465+
if listOptions.Page > 0 {
466466
sess = db.SetSessionPagination(sess, &listOptions)
467467
}
468468

models/issues/reaction.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ func FindReactions(ctx context.Context, opts FindReactionsOptions) (ReactionList
163163
Where(opts.toConds()).
164164
In("reaction.`type`", setting.UI.Reactions).
165165
Asc("reaction.issue_id", "reaction.comment_id", "reaction.created_unix", "reaction.id")
166-
if opts.Page != 0 {
166+
if opts.Page > 0 {
167167
sess = db.SetSessionPagination(sess, &opts)
168168

169169
reactions := make([]*Reaction, 0, opts.PageSize)

models/issues/stopwatch.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func GetUIDsAndStopwatch(ctx context.Context) ([]*UserStopwatch, error) {
9696
func GetUserStopwatches(ctx context.Context, userID int64, listOptions db.ListOptions) ([]*Stopwatch, error) {
9797
sws := make([]*Stopwatch, 0, 8)
9898
sess := db.GetEngine(ctx).Where("stopwatch.user_id = ?", userID)
99-
if listOptions.Page != 0 {
99+
if listOptions.Page > 0 {
100100
sess = db.SetSessionPagination(sess, &listOptions)
101101
}
102102

models/issues/tracked_time.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ func (opts *FindTrackedTimesOptions) toSession(e db.Engine) db.Engine {
139139

140140
sess = sess.Where(opts.ToConds())
141141

142-
if opts.Page != 0 {
142+
if opts.Page > 0 {
143143
sess = db.SetSessionPagination(sess, opts)
144144
}
145145

models/user/search.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ func SearchUsers(ctx context.Context, opts *SearchUserOptions) (users []*User, _
152152

153153
sessQuery := opts.toSearchQueryBase(ctx).OrderBy(opts.OrderBy.String())
154154
defer sessQuery.Close()
155-
if opts.Page != 0 {
155+
if opts.Page > 0 {
156156
sessQuery = db.SetSessionPagination(sessQuery, opts)
157157
}
158158

models/user/user.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ func GetUserFollowers(ctx context.Context, u, viewer *User, listOptions db.ListO
330330
And("`user`.type=?", UserTypeIndividual).
331331
And(isUserVisibleToViewerCond(viewer))
332332

333-
if listOptions.Page != 0 {
333+
if listOptions.Page > 0 {
334334
sess = db.SetSessionPagination(sess, &listOptions)
335335

336336
users := make([]*User, 0, listOptions.PageSize)
@@ -352,7 +352,7 @@ func GetUserFollowing(ctx context.Context, u, viewer *User, listOptions db.ListO
352352
And("`user`.type IN (?, ?)", UserTypeIndividual, UserTypeOrganization).
353353
And(isUserVisibleToViewerCond(viewer))
354354

355-
if listOptions.Page != 0 {
355+
if listOptions.Page > 0 {
356356
sess = db.SetSessionPagination(sess, &listOptions)
357357

358358
users := make([]*User, 0, listOptions.PageSize)

0 commit comments

Comments
 (0)