mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 08:30:25 +08:00 
			
		
		
		
	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:
		@@ -16,8 +16,8 @@ import (
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// CreateComment creates comment of issue or commit.
 | 
			
		||||
func CreateComment(opts *issues_model.CreateCommentOptions) (comment *issues_model.Comment, err error) {
 | 
			
		||||
	ctx, committer, err := db.TxContext(db.DefaultContext)
 | 
			
		||||
func CreateComment(ctx context.Context, opts *issues_model.CreateCommentOptions) (comment *issues_model.Comment, err error) {
 | 
			
		||||
	ctx, committer, err := db.TxContext(ctx)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
@@ -53,7 +53,7 @@ func CreateRefComment(doer *user_model.User, repo *repo_model.Repository, issue
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	_, err = CreateComment(&issues_model.CreateCommentOptions{
 | 
			
		||||
	_, err = CreateComment(db.DefaultContext, &issues_model.CreateCommentOptions{
 | 
			
		||||
		Type:      issues_model.CommentTypeCommitRef,
 | 
			
		||||
		Doer:      doer,
 | 
			
		||||
		Repo:      repo,
 | 
			
		||||
@@ -66,7 +66,7 @@ func CreateRefComment(doer *user_model.User, repo *repo_model.Repository, issue
 | 
			
		||||
 | 
			
		||||
// CreateIssueComment creates a plain issue comment.
 | 
			
		||||
func CreateIssueComment(ctx context.Context, doer *user_model.User, repo *repo_model.Repository, issue *issues_model.Issue, content string, attachments []string) (*issues_model.Comment, error) {
 | 
			
		||||
	comment, err := CreateComment(&issues_model.CreateCommentOptions{
 | 
			
		||||
	comment, err := CreateComment(ctx, &issues_model.CreateCommentOptions{
 | 
			
		||||
		Type:        issues_model.CommentTypeComment,
 | 
			
		||||
		Doer:        doer,
 | 
			
		||||
		Repo:        repo,
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user