From 7a42e3574102fdd54845f7f626a99419bf6f41b9 Mon Sep 17 00:00:00 2001
From: Gusted <williamzijl7@hotmail.com>
Date: Sun, 6 Feb 2022 13:05:07 +0100
Subject: [PATCH] Pass correct context (#18638)

- Pass the correct context into `db.GetEngine()`.
- Introduced in: https://github.com/go-gitea/gitea/pull/18604
---
 models/user/user.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/models/user/user.go b/models/user/user.go
index 5ed850bdfa..bd55249448 100644
--- a/models/user/user.go
+++ b/models/user/user.go
@@ -1028,7 +1028,7 @@ func GetUserNamesByIDs(ids []int64) ([]string, error) {
 // GetUserNameByID returns username for the id
 func GetUserNameByID(ctx context.Context, id int64) (string, error) {
 	var name string
-	has, err := db.GetEngine(db.DefaultContext).Table("user").Where("id = ?", id).Cols("name").Get(&name)
+	has, err := db.GetEngine(ctx).Table("user").Where("id = ?", id).Cols("name").Get(&name)
 	if err != nil {
 		return "", err
 	}