Make more functions use ctx instead of db.DefaultContext (#24068)
Continue the "ctx refactoring" work. There are still a lot db.DefaultContext, incorrect context could cause database deadlock errors.
This commit is contained in:
parent
b667634b32
commit
cfe3d6e9b5
17 changed files with 79 additions and 79 deletions
|
@ -651,7 +651,7 @@ func CreateIssue(ctx *context.APIContext) {
|
|||
form.Labels = make([]int64, 0)
|
||||
}
|
||||
|
||||
if err := issue_service.NewIssue(ctx.Repo.Repository, issue, form.Labels, nil, assigneeIDs); err != nil {
|
||||
if err := issue_service.NewIssue(ctx, ctx.Repo.Repository, issue, form.Labels, nil, assigneeIDs); err != nil {
|
||||
if repo_model.IsErrUserDoesNotHaveAccessToRepo(err) {
|
||||
ctx.Error(http.StatusBadRequest, "UserDoesNotHaveAccessToRepo", err)
|
||||
return
|
||||
|
@ -752,7 +752,7 @@ func EditIssue(ctx *context.APIContext) {
|
|||
issue.Content = *form.Body
|
||||
}
|
||||
if form.Ref != nil {
|
||||
err = issue_service.ChangeIssueRef(issue, ctx.Doer, *form.Ref)
|
||||
err = issue_service.ChangeIssueRef(ctx, issue, ctx.Doer, *form.Ref)
|
||||
if err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "UpdateRef", err)
|
||||
return
|
||||
|
@ -790,7 +790,7 @@ func EditIssue(ctx *context.APIContext) {
|
|||
oneAssignee = *form.Assignee
|
||||
}
|
||||
|
||||
err = issue_service.UpdateAssignees(issue, oneAssignee, form.Assignees, ctx.Doer)
|
||||
err = issue_service.UpdateAssignees(ctx, issue, oneAssignee, form.Assignees, ctx.Doer)
|
||||
if err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "UpdateAssignees", err)
|
||||
return
|
||||
|
@ -887,7 +887,7 @@ func DeleteIssue(ctx *context.APIContext) {
|
|||
return
|
||||
}
|
||||
|
||||
if err = issue_service.DeleteIssue(ctx.Doer, ctx.Repo.GitRepo, issue); err != nil {
|
||||
if err = issue_service.DeleteIssue(ctx, ctx.Doer, ctx.Repo.GitRepo, issue); err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "DeleteIssueByID", err)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -534,7 +534,7 @@ func EditPullRequest(ctx *context.APIContext) {
|
|||
// Send an empty array ([]) to clear all assignees from the Issue.
|
||||
|
||||
if ctx.Repo.CanWrite(unit.TypePullRequests) && (form.Assignees != nil || len(form.Assignee) > 0) {
|
||||
err = issue_service.UpdateAssignees(issue, form.Assignee, form.Assignees, ctx.Doer)
|
||||
err = issue_service.UpdateAssignees(ctx, issue, form.Assignee, form.Assignees, ctx.Doer)
|
||||
if err != nil {
|
||||
if user_model.IsErrUserNotExist(err) {
|
||||
ctx.Error(http.StatusUnprocessableEntity, "", fmt.Sprintf("Assignee does not exist: [name: %s]", err))
|
||||
|
|
|
@ -706,7 +706,7 @@ func apiReviewRequest(ctx *context.APIContext, opts api.PullReviewRequestOptions
|
|||
}
|
||||
|
||||
for _, reviewer := range reviewers {
|
||||
comment, err := issue_service.ReviewRequest(pr.Issue, ctx.Doer, reviewer, isAdd)
|
||||
comment, err := issue_service.ReviewRequest(ctx, pr.Issue, ctx.Doer, reviewer, isAdd)
|
||||
if err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "ReviewRequest", err)
|
||||
return
|
||||
|
@ -750,7 +750,7 @@ func apiReviewRequest(ctx *context.APIContext, opts api.PullReviewRequestOptions
|
|||
}
|
||||
|
||||
for _, teamReviewer := range teamReviewers {
|
||||
comment, err := issue_service.TeamReviewRequest(pr.Issue, ctx.Doer, teamReviewer, isAdd)
|
||||
comment, err := issue_service.TeamReviewRequest(ctx, pr.Issue, ctx.Doer, teamReviewer, isAdd)
|
||||
if err != nil {
|
||||
ctx.ServerError("TeamReviewRequest", err)
|
||||
return
|
||||
|
|
|
@ -964,7 +964,7 @@ func DeleteIssue(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if err := issue_service.DeleteIssue(ctx.Doer, ctx.Repo.GitRepo, issue); err != nil {
|
||||
if err := issue_service.DeleteIssue(ctx, ctx.Doer, ctx.Repo.GitRepo, issue); err != nil {
|
||||
ctx.ServerError("DeleteIssueByID", err)
|
||||
return
|
||||
}
|
||||
|
@ -1132,7 +1132,7 @@ func NewIssuePost(ctx *context.Context) {
|
|||
Ref: form.Ref,
|
||||
}
|
||||
|
||||
if err := issue_service.NewIssue(repo, issue, labelIDs, attachments, assigneeIDs); err != nil {
|
||||
if err := issue_service.NewIssue(ctx, repo, issue, labelIDs, attachments, assigneeIDs); err != nil {
|
||||
if repo_model.IsErrUserDoesNotHaveAccessToRepo(err) {
|
||||
ctx.Error(http.StatusBadRequest, "UserDoesNotHaveAccessToRepo", err.Error())
|
||||
return
|
||||
|
@ -2013,7 +2013,7 @@ func UpdateIssueTitle(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if err := issue_service.ChangeTitle(issue, ctx.Doer, title); err != nil {
|
||||
if err := issue_service.ChangeTitle(ctx, issue, ctx.Doer, title); err != nil {
|
||||
ctx.ServerError("ChangeTitle", err)
|
||||
return
|
||||
}
|
||||
|
@ -2037,7 +2037,7 @@ func UpdateIssueRef(ctx *context.Context) {
|
|||
|
||||
ref := ctx.FormTrim("ref")
|
||||
|
||||
if err := issue_service.ChangeIssueRef(issue, ctx.Doer, ref); err != nil {
|
||||
if err := issue_service.ChangeIssueRef(ctx, issue, ctx.Doer, ref); err != nil {
|
||||
ctx.ServerError("ChangeRef", err)
|
||||
return
|
||||
}
|
||||
|
@ -2161,7 +2161,7 @@ func UpdateIssueAssignee(ctx *context.Context) {
|
|||
for _, issue := range issues {
|
||||
switch action {
|
||||
case "clear":
|
||||
if err := issue_service.DeleteNotPassedAssignee(issue, ctx.Doer, []*user_model.User{}); err != nil {
|
||||
if err := issue_service.DeleteNotPassedAssignee(ctx, issue, ctx.Doer, []*user_model.User{}); err != nil {
|
||||
ctx.ServerError("ClearAssignees", err)
|
||||
return
|
||||
}
|
||||
|
@ -2182,7 +2182,7 @@ func UpdateIssueAssignee(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
_, _, err = issue_service.ToggleAssignee(issue, ctx.Doer, assigneeID)
|
||||
_, _, err = issue_service.ToggleAssignee(ctx, issue, ctx.Doer, assigneeID)
|
||||
if err != nil {
|
||||
ctx.ServerError("ToggleAssignee", err)
|
||||
return
|
||||
|
@ -2269,7 +2269,7 @@ func UpdatePullReviewRequest(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
_, err = issue_service.TeamReviewRequest(issue, ctx.Doer, team, action == "attach")
|
||||
_, err = issue_service.TeamReviewRequest(ctx, issue, ctx.Doer, team, action == "attach")
|
||||
if err != nil {
|
||||
ctx.ServerError("TeamReviewRequest", err)
|
||||
return
|
||||
|
@ -2307,7 +2307,7 @@ func UpdatePullReviewRequest(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
_, err = issue_service.ReviewRequest(issue, ctx.Doer, reviewer, action == "attach")
|
||||
_, err = issue_service.ReviewRequest(ctx, issue, ctx.Doer, reviewer, action == "attach")
|
||||
if err != nil {
|
||||
ctx.ServerError("ReviewRequest", err)
|
||||
return
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue