1
0
Fork 0
forked from forgejo/forgejo

Fix misuse of TxContext (#30061)

Help #29999, or its tests cannot pass.

Also, add some comments to clarify the usage of `TxContext`.

I don't check all usages of `TxContext` because there are too many
(almost 140+). It's a better idea to replace them with `WithTx` instead
of checking them one by one. However, that may be another refactoring
PR.

(cherry picked from commit c6c4d66004c70b24abc8048b39b660b8361a0395)
This commit is contained in:
Jason Song 2024-03-25 15:00:16 +08:00 committed by Earl Warren
parent 8e3e31a566
commit 2c4e85421e
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00
2 changed files with 11 additions and 1 deletions

View file

@ -620,7 +620,7 @@ func AddReviewRequest(ctx context.Context, issue *Issue, reviewer, doer *user_mo
// skip it when reviewer hase been request to review
if review != nil && review.Type == ReviewTypeRequest {
return nil, nil
return nil, committer.Commit() // still commit the transaction, or committer.Close() will rollback it, even if it's a reused transaction.
}
// if the reviewer is an official reviewer,