diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2024-11-24 17:56:50 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-25 09:56:50 +0800 |
commit | c363bd06e93986a564601527ade219d602c9d8dd (patch) | |
tree | 91b7e328dde7c2788736711df40f34bbf18e3abf /models/issues | |
parent | 633785a5f3fe00789a6cba7cc0db1333de1e9c52 (diff) | |
download | gitea-c363bd06e93986a564601527ade219d602c9d8dd.tar.gz gitea-c363bd06e93986a564601527ade219d602c9d8dd.zip |
Strict pagination check (#32548)
Diffstat (limited to 'models/issues')
-rw-r--r-- | models/issues/comment.go | 2 | ||||
-rw-r--r-- | models/issues/issue.go | 2 | ||||
-rw-r--r-- | models/issues/issue_watch.go | 2 | ||||
-rw-r--r-- | models/issues/label.go | 4 | ||||
-rw-r--r-- | models/issues/reaction.go | 2 | ||||
-rw-r--r-- | models/issues/stopwatch.go | 2 | ||||
-rw-r--r-- | models/issues/tracked_time.go | 2 |
7 files changed, 8 insertions, 8 deletions
diff --git a/models/issues/comment.go b/models/issues/comment.go index 48b8e335d4..6650817e50 100644 --- a/models/issues/comment.go +++ b/models/issues/comment.go @@ -1108,7 +1108,7 @@ func FindComments(ctx context.Context, opts *FindCommentsOptions) (CommentList, sess.Join("INNER", "issue", "issue.id = comment.issue_id") } - if opts.Page != 0 { + if opts.Page > 0 { sess = db.SetSessionPagination(sess, opts) } diff --git a/models/issues/issue.go b/models/issues/issue.go index 9ccf2859ea..fd89267b84 100644 --- a/models/issues/issue.go +++ b/models/issues/issue.go @@ -641,7 +641,7 @@ func (issue *Issue) BlockedByDependencies(ctx context.Context, opts db.ListOptio Where("issue_id = ?", issue.ID). // sort by repo id then created date, with the issues of the same repo at the beginning of the list OrderBy("CASE WHEN issue.repo_id = ? THEN 0 ELSE issue.repo_id END, issue.created_unix DESC", issue.RepoID) - if opts.Page != 0 { + if opts.Page > 0 { sess = db.SetSessionPagination(sess, &opts) } err = sess.Find(&issueDeps) diff --git a/models/issues/issue_watch.go b/models/issues/issue_watch.go index 9e616a0eb1..560be17eb6 100644 --- a/models/issues/issue_watch.go +++ b/models/issues/issue_watch.go @@ -105,7 +105,7 @@ func GetIssueWatchers(ctx context.Context, issueID int64, listOptions db.ListOpt And("`user`.prohibit_login = ?", false). Join("INNER", "`user`", "`user`.id = `issue_watch`.user_id") - if listOptions.Page != 0 { + if listOptions.Page > 0 { sess = db.SetSessionPagination(sess, &listOptions) watches := make([]*IssueWatch, 0, listOptions.PageSize) return watches, sess.Find(&watches) diff --git a/models/issues/label.go b/models/issues/label.go index 2530f71004..d80578193e 100644 --- a/models/issues/label.go +++ b/models/issues/label.go @@ -390,7 +390,7 @@ func GetLabelsByRepoID(ctx context.Context, repoID int64, sortType string, listO sess.Asc("name") } - if listOptions.Page != 0 { + if listOptions.Page > 0 { sess = db.SetSessionPagination(sess, &listOptions) } @@ -462,7 +462,7 @@ func GetLabelsByOrgID(ctx context.Context, orgID int64, sortType string, listOpt sess.Asc("name") } - if listOptions.Page != 0 { + if listOptions.Page > 0 { sess = db.SetSessionPagination(sess, &listOptions) } diff --git a/models/issues/reaction.go b/models/issues/reaction.go index eb7faefc79..11b3c6be20 100644 --- a/models/issues/reaction.go +++ b/models/issues/reaction.go @@ -163,7 +163,7 @@ func FindReactions(ctx context.Context, opts FindReactionsOptions) (ReactionList Where(opts.toConds()). In("reaction.`type`", setting.UI.Reactions). Asc("reaction.issue_id", "reaction.comment_id", "reaction.created_unix", "reaction.id") - if opts.Page != 0 { + if opts.Page > 0 { sess = db.SetSessionPagination(sess, &opts) reactions := make([]*Reaction, 0, opts.PageSize) diff --git a/models/issues/stopwatch.go b/models/issues/stopwatch.go index fd9c7d7875..629af95b57 100644 --- a/models/issues/stopwatch.go +++ b/models/issues/stopwatch.go @@ -96,7 +96,7 @@ func GetUIDsAndStopwatch(ctx context.Context) ([]*UserStopwatch, error) { func GetUserStopwatches(ctx context.Context, userID int64, listOptions db.ListOptions) ([]*Stopwatch, error) { sws := make([]*Stopwatch, 0, 8) sess := db.GetEngine(ctx).Where("stopwatch.user_id = ?", userID) - if listOptions.Page != 0 { + if listOptions.Page > 0 { sess = db.SetSessionPagination(sess, &listOptions) } diff --git a/models/issues/tracked_time.go b/models/issues/tracked_time.go index caa582a9fc..ea404d36cd 100644 --- a/models/issues/tracked_time.go +++ b/models/issues/tracked_time.go @@ -139,7 +139,7 @@ func (opts *FindTrackedTimesOptions) toSession(e db.Engine) db.Engine { sess = sess.Where(opts.ToConds()) - if opts.Page != 0 { + if opts.Page > 0 { sess = db.SetSessionPagination(sess, opts) } |