Browse Source

DB transactions with context

Vova Tkach 5 years ago
parent
commit
ebd4ac9d4b

+ 2 - 2
engine/sqlw/sqlw.go

@@ -111,7 +111,7 @@ func (this *DB) Exec(ctx context.Context, query string, args ...interface{}) (sq
 	return this.db.ExecContext(ctx, query, args...)
 }
 
-func (this *DB) Transaction(ctx context.Context, queries func(tx *Tx) error) error {
+func (this *DB) Transaction(ctx context.Context, queries func(ctx context.Context, tx *Tx) error) error {
 	if queries == nil {
 		return errors.New("queries is not set for transaction")
 	}
@@ -119,7 +119,7 @@ func (this *DB) Transaction(ctx context.Context, queries func(tx *Tx) error) err
 	if err != nil {
 		return err
 	}
-	if err := queries(tx); err != nil {
+	if err := queries(ctx, tx); err != nil {
 		tx.Rollback()
 		return err
 	}

+ 3 - 1
modules/module_blog_act_delete.go

@@ -1,6 +1,8 @@
 package modules
 
 import (
+	"context"
+
 	"golang-fave/engine/wrapper"
 	"golang-fave/utils"
 )
@@ -18,7 +20,7 @@ func (this *Modules) RegisterAction_BlogDelete() *Action {
 			return
 		}
 
-		if err := wrap.DB.Transaction(wrap.R.Context(), func(tx *wrapper.Tx) error {
+		if err := wrap.DB.Transaction(wrap.R.Context(), func(ctx context.Context, tx *wrapper.Tx) error {
 			// Block rows
 			if _, err := tx.Exec("SELECT id FROM blog_posts WHERE id = ? FOR UPDATE;", utils.StrToInt(pf_id)); err != nil {
 				return err

+ 3 - 2
modules/module_blog_act_modify.go

@@ -1,6 +1,7 @@
 package modules
 
 import (
+	"context"
 	"errors"
 	"strings"
 
@@ -57,7 +58,7 @@ func (this *Modules) RegisterAction_BlogModify() *Action {
 
 		if pf_id == "0" {
 			var lastID int64 = 0
-			if err := wrap.DB.Transaction(wrap.R.Context(), func(tx *wrapper.Tx) error {
+			if err := wrap.DB.Transaction(wrap.R.Context(), func(ctx context.Context, tx *wrapper.Tx) error {
 				// Insert row
 				res, err := tx.Exec(
 					`INSERT INTO blog_posts SET
@@ -133,7 +134,7 @@ func (this *Modules) RegisterAction_BlogModify() *Action {
 			wrap.ResetCacheBlocks()
 			wrap.Write(`window.location='/cp/blog/modify/` + utils.Int64ToStr(lastID) + `/';`)
 		} else {
-			if err := wrap.DB.Transaction(wrap.R.Context(), func(tx *wrapper.Tx) error {
+			if err := wrap.DB.Transaction(wrap.R.Context(), func(ctx context.Context, tx *wrapper.Tx) error {
 				// Block rows
 				if _, err := tx.Exec("SELECT id FROM blog_posts WHERE id = ? FOR UPDATE;", utils.StrToInt(pf_id)); err != nil {
 					return err

+ 3 - 1
modules/module_blog_categories_act_delete.go

@@ -1,6 +1,8 @@
 package modules
 
 import (
+	"context"
+
 	"golang-fave/engine/wrapper"
 	"golang-fave/utils"
 )
@@ -18,7 +20,7 @@ func (this *Modules) RegisterAction_BlogCategoriesDelete() *Action {
 			return
 		}
 
-		err := wrap.DB.Transaction(wrap.R.Context(), func(tx *wrapper.Tx) error {
+		err := wrap.DB.Transaction(wrap.R.Context(), func(ctx context.Context, tx *wrapper.Tx) error {
 			// Block rows
 			if _, err := tx.Exec("SELECT id FROM blog_cats FOR UPDATE;"); err != nil {
 				return err

+ 4 - 3
modules/module_blog_categories_act_modify.go

@@ -1,6 +1,7 @@
 package modules
 
 import (
+	"context"
 	"errors"
 
 	"golang-fave/engine/wrapper"
@@ -9,7 +10,7 @@ import (
 
 func (this *Modules) blog_ActionCategoryAdd(wrap *wrapper.Wrapper, pf_id, pf_name, pf_alias, pf_parent string) (error, int64) {
 	var lastID int64 = 0
-	return wrap.DB.Transaction(wrap.R.Context(), func(tx *wrapper.Tx) error {
+	return wrap.DB.Transaction(wrap.R.Context(), func(ctx context.Context, tx *wrapper.Tx) error {
 		// Block rows
 		if _, err := tx.Exec("SELECT id FROM blog_cats FOR UPDATE;"); err != nil {
 			return err
@@ -45,7 +46,7 @@ func (this *Modules) blog_ActionCategoryUpdate(wrap *wrapper.Wrapper, pf_id, pf_
 
 	if utils.StrToInt(pf_parent) == parentId {
 		// If parent not changed, just update category data
-		return wrap.DB.Transaction(wrap.R.Context(), func(tx *wrapper.Tx) error {
+		return wrap.DB.Transaction(wrap.R.Context(), func(ctx context.Context, tx *wrapper.Tx) error {
 			// Process
 			if _, err := tx.Exec(`
 				UPDATE blog_cats SET
@@ -68,7 +69,7 @@ func (this *Modules) blog_ActionCategoryUpdate(wrap *wrapper.Wrapper, pf_id, pf_
 	// TODO: Fix parent change
 
 	// Parent is changed, move category to new parent
-	return wrap.DB.Transaction(wrap.R.Context(), func(tx *wrapper.Tx) error {
+	return wrap.DB.Transaction(wrap.R.Context(), func(ctx context.Context, tx *wrapper.Tx) error {
 		// Block all rows
 		if _, err := tx.Exec("SELECT id FROM blog_cats FOR UPDATE;"); err != nil {
 			return err

+ 3 - 1
modules/module_index_act_delete.go

@@ -1,6 +1,8 @@
 package modules
 
 import (
+	"context"
+
 	"golang-fave/engine/wrapper"
 	"golang-fave/utils"
 )
@@ -18,7 +20,7 @@ func (this *Modules) RegisterAction_IndexDelete() *Action {
 			return
 		}
 
-		err := wrap.DB.Transaction(wrap.R.Context(), func(tx *wrapper.Tx) error {
+		err := wrap.DB.Transaction(wrap.R.Context(), func(ctx context.Context, tx *wrapper.Tx) error {
 			// Process
 			if _, err := tx.Exec("DELETE FROM pages WHERE id = ?;", utils.StrToInt(pf_id)); err != nil {
 				return err

+ 4 - 2
modules/module_index_act_modify.go

@@ -1,6 +1,8 @@
 package modules
 
 import (
+	"context"
+
 	"golang-fave/engine/wrapper"
 	"golang-fave/utils"
 )
@@ -46,7 +48,7 @@ func (this *Modules) RegisterAction_IndexModify() *Action {
 		if pf_id == "0" {
 			// Add new page
 			var lastID int64 = 0
-			if err := wrap.DB.Transaction(wrap.R.Context(), func(tx *wrapper.Tx) error {
+			if err := wrap.DB.Transaction(wrap.R.Context(), func(ctx context.Context, tx *wrapper.Tx) error {
 				res, err := tx.Exec(
 					`INSERT INTO pages SET
 						user = ?,
@@ -86,7 +88,7 @@ func (this *Modules) RegisterAction_IndexModify() *Action {
 			wrap.Write(`window.location='/cp/index/modify/` + utils.Int64ToStr(lastID) + `/';`)
 		} else {
 			// Update page
-			if err := wrap.DB.Transaction(wrap.R.Context(), func(tx *wrapper.Tx) error {
+			if err := wrap.DB.Transaction(wrap.R.Context(), func(ctx context.Context, tx *wrapper.Tx) error {
 				_, err := tx.Exec(
 					`UPDATE pages SET
 						name = ?,

+ 2 - 1
modules/module_shop_act_attach_product_to.go

@@ -1,6 +1,7 @@
 package modules
 
 import (
+	"context"
 	"errors"
 
 	"golang-fave/engine/wrapper"
@@ -21,7 +22,7 @@ func (this *Modules) RegisterAction_ShopAttachProductTo() *Action {
 			return
 		}
 
-		if err := wrap.DB.Transaction(wrap.R.Context(), func(tx *wrapper.Tx) error {
+		if err := wrap.DB.Transaction(wrap.R.Context(), func(ctx context.Context, tx *wrapper.Tx) error {
 			// Check parent
 			var count int
 			if err := tx.QueryRow(

+ 3 - 1
modules/module_shop_act_delete.go

@@ -1,6 +1,8 @@
 package modules
 
 import (
+	"context"
+
 	"golang-fave/engine/wrapper"
 	"golang-fave/utils"
 )
@@ -18,7 +20,7 @@ func (this *Modules) RegisterAction_ShopDelete() *Action {
 			return
 		}
 
-		if err := wrap.DB.Transaction(wrap.R.Context(), func(tx *wrapper.Tx) error {
+		if err := wrap.DB.Transaction(wrap.R.Context(), func(ctx context.Context, tx *wrapper.Tx) error {
 			// Block rows
 			if _, err := tx.Exec("SELECT id FROM shop_products WHERE id = ? FOR UPDATE;", utils.StrToInt(pf_id)); err != nil {
 				return err

+ 3 - 1
modules/module_shop_act_detach.go

@@ -1,6 +1,8 @@
 package modules
 
 import (
+	"context"
+
 	"golang-fave/engine/wrapper"
 	"golang-fave/utils"
 )
@@ -18,7 +20,7 @@ func (this *Modules) RegisterAction_ShopDetach() *Action {
 			return
 		}
 
-		if err := wrap.DB.Transaction(wrap.R.Context(), func(tx *wrapper.Tx) error {
+		if err := wrap.DB.Transaction(wrap.R.Context(), func(ctx context.Context, tx *wrapper.Tx) error {
 			if _, err := tx.Exec(`
 				UPDATE shop_products SET
 					parent_id = NULL,

+ 2 - 1
modules/module_shop_act_duplicate.go

@@ -1,6 +1,7 @@
 package modules
 
 import (
+	"context"
 	"time"
 
 	"golang-fave/engine/wrapper"
@@ -22,7 +23,7 @@ func (this *Modules) RegisterAction_ShopDuplicate() *Action {
 		}
 
 		var lastID int64 = 0
-		if err := wrap.DB.Transaction(wrap.R.Context(), func(tx *wrapper.Tx) error {
+		if err := wrap.DB.Transaction(wrap.R.Context(), func(ctx context.Context, tx *wrapper.Tx) error {
 			// Block rows
 			if _, err := tx.Exec("SELECT id FROM shop_products WHERE id = ? FOR UPDATE;", utils.StrToInt(pf_id)); err != nil {
 				return err

+ 2 - 1
modules/module_shop_act_images_reorder.go

@@ -1,6 +1,7 @@
 package modules
 
 import (
+	"context"
 	"encoding/json"
 
 	"golang-fave/engine/wrapper"
@@ -31,7 +32,7 @@ func (this *Modules) RegisterAction_ShopImagesReorder() *Action {
 		}
 
 		if len(orders.Items) > 0 {
-			if err := wrap.DB.Transaction(wrap.R.Context(), func(tx *wrapper.Tx) error {
+			if err := wrap.DB.Transaction(wrap.R.Context(), func(ctx context.Context, tx *wrapper.Tx) error {
 				for _, value := range orders.Items {
 					if _, err := tx.Exec("UPDATE shop_product_images SET ord = ? WHERE id = ?;", value.Order, value.Id); err != nil {
 						return err

+ 3 - 2
modules/module_shop_act_modify.go

@@ -1,6 +1,7 @@
 package modules
 
 import (
+	"context"
 	"errors"
 	"strings"
 
@@ -103,7 +104,7 @@ func (this *Modules) RegisterAction_ShopModify() *Action {
 
 		if pf_id == "0" {
 			var lastID int64 = 0
-			if err := wrap.DB.Transaction(wrap.R.Context(), func(tx *wrapper.Tx) error {
+			if err := wrap.DB.Transaction(wrap.R.Context(), func(ctx context.Context, tx *wrapper.Tx) error {
 				// Insert row
 				res, err := tx.Exec(
 					`INSERT INTO shop_products SET
@@ -215,7 +216,7 @@ func (this *Modules) RegisterAction_ShopModify() *Action {
 
 			wrap.Write(`window.location='/cp/shop/modify/` + utils.Int64ToStr(lastID) + `/';`)
 		} else {
-			if err := wrap.DB.Transaction(wrap.R.Context(), func(tx *wrapper.Tx) error {
+			if err := wrap.DB.Transaction(wrap.R.Context(), func(ctx context.Context, tx *wrapper.Tx) error {
 				// Block rows
 				if _, err := tx.Exec("SELECT id FROM shop_products WHERE id = ? FOR UPDATE;", utils.StrToInt(pf_id)); err != nil {
 					return err

+ 3 - 1
modules/module_shop_act_order.go

@@ -1,6 +1,8 @@
 package modules
 
 import (
+	"context"
+
 	"golang-fave/consts"
 	"golang-fave/engine/basket"
 	"golang-fave/engine/wrapper"
@@ -97,7 +99,7 @@ func (this *Modules) RegisterAction_ShopOrder() *Action {
 		})
 
 		var lastID int64 = 0
-		if err := wrap.DB.Transaction(wrap.R.Context(), func(tx *wrapper.Tx) error {
+		if err := wrap.DB.Transaction(wrap.R.Context(), func(ctx context.Context, tx *wrapper.Tx) error {
 			// Insert row
 			res, err := tx.Exec(
 				`INSERT INTO shop_orders SET

+ 3 - 1
modules/module_shop_act_order_set_status.go

@@ -1,6 +1,8 @@
 package modules
 
 import (
+	"context"
+
 	"golang-fave/engine/wrapper"
 	"golang-fave/utils"
 )
@@ -29,7 +31,7 @@ func (this *Modules) RegisterAction_ShopOrderSetStatus() *Action {
 			return
 		}
 
-		if err := wrap.DB.Transaction(wrap.R.Context(), func(tx *wrapper.Tx) error {
+		if err := wrap.DB.Transaction(wrap.R.Context(), func(ctx context.Context, tx *wrapper.Tx) error {
 			if _, err := tx.Exec(
 				`UPDATE shop_orders SET
 					status = ?

+ 2 - 1
modules/module_shop_act_upload_delete.go

@@ -1,6 +1,7 @@
 package modules
 
 import (
+	"context"
 	"os"
 
 	"golang-fave/engine/wrapper"
@@ -26,7 +27,7 @@ func (this *Modules) RegisterAction_ShopUploadDelete() *Action {
 			return
 		}
 
-		if err := wrap.DB.Transaction(wrap.R.Context(), func(tx *wrapper.Tx) error {
+		if err := wrap.DB.Transaction(wrap.R.Context(), func(ctx context.Context, tx *wrapper.Tx) error {
 			// Block rows
 			if _, err := tx.Exec("SELECT id FROM shop_products WHERE id = ? FOR UPDATE;", utils.StrToInt(pf_id)); err != nil {
 				return err

+ 2 - 1
modules/module_shop_act_upload_image.go

@@ -2,6 +2,7 @@ package modules
 
 import (
 	"bytes"
+	"context"
 	"image"
 	"io/ioutil"
 	"os"
@@ -52,7 +53,7 @@ func (this *Modules) RegisterAction_ShopUploadImage() *Action {
 								target_file_name := utils.Int64ToStr(time.Now().Unix()+int64(i-1)) + filepath.Ext(handler.Filename)
 								target_file_full := wrap.DHtdocs + string(os.PathSeparator) + "products" + string(os.PathSeparator) + "images" + string(os.PathSeparator) + pf_id + string(os.PathSeparator) + target_file_name
 								var lastID int64 = 0
-								if err := wrap.DB.Transaction(wrap.R.Context(), func(tx *wrapper.Tx) error {
+								if err := wrap.DB.Transaction(wrap.R.Context(), func(ctx context.Context, tx *wrapper.Tx) error {
 									// Block rows
 									if _, err := tx.Exec("SELECT id FROM shop_products WHERE id = ? FOR UPDATE;", utils.StrToInt(pf_id)); err != nil {
 										return err

+ 3 - 1
modules/module_shop_attributes_act_delete.go

@@ -1,6 +1,8 @@
 package modules
 
 import (
+	"context"
+
 	"golang-fave/engine/wrapper"
 	"golang-fave/utils"
 )
@@ -18,7 +20,7 @@ func (this *Modules) RegisterAction_ShopAttributesDelete() *Action {
 			return
 		}
 
-		err := wrap.DB.Transaction(wrap.R.Context(), func(tx *wrapper.Tx) error {
+		err := wrap.DB.Transaction(wrap.R.Context(), func(ctx context.Context, tx *wrapper.Tx) error {
 			// Block rows
 			if _, err := tx.Exec("SELECT id FROM shop_filters WHERE id = ? FOR UPDATE;", utils.StrToInt(pf_id)); err != nil {
 				return err

+ 3 - 2
modules/module_shop_attributes_act_modify.go

@@ -1,6 +1,7 @@
 package modules
 
 import (
+	"context"
 	"strings"
 
 	"golang-fave/engine/wrapper"
@@ -46,7 +47,7 @@ func (this *Modules) RegisterAction_ShopAttributesModify() *Action {
 
 		if pf_id == "0" {
 			var lastID int64 = 0
-			if err := wrap.DB.Transaction(wrap.R.Context(), func(tx *wrapper.Tx) error {
+			if err := wrap.DB.Transaction(wrap.R.Context(), func(ctx context.Context, tx *wrapper.Tx) error {
 				// Insert row
 				res, err := tx.Exec(
 					`INSERT INTO shop_filters SET
@@ -96,7 +97,7 @@ func (this *Modules) RegisterAction_ShopAttributesModify() *Action {
 
 			wrap.Write(`window.location='/cp/shop/attributes-modify/` + utils.Int64ToStr(lastID) + `/';`)
 		} else {
-			if err := wrap.DB.Transaction(wrap.R.Context(), func(tx *wrapper.Tx) error {
+			if err := wrap.DB.Transaction(wrap.R.Context(), func(ctx context.Context, tx *wrapper.Tx) error {
 				// Block rows
 				if _, err := tx.Exec("SELECT id FROM shop_filters WHERE id = ? FOR UPDATE;", utils.StrToInt(pf_id)); err != nil {
 					return err

+ 3 - 1
modules/module_shop_categories_act_delete.go

@@ -1,6 +1,8 @@
 package modules
 
 import (
+	"context"
+
 	"golang-fave/engine/wrapper"
 	"golang-fave/utils"
 )
@@ -18,7 +20,7 @@ func (this *Modules) RegisterAction_ShopCategoriesDelete() *Action {
 			return
 		}
 
-		err := wrap.DB.Transaction(wrap.R.Context(), func(tx *wrapper.Tx) error {
+		err := wrap.DB.Transaction(wrap.R.Context(), func(ctx context.Context, tx *wrapper.Tx) error {
 			// Block rows
 			if _, err := tx.Exec("SELECT id FROM shop_cats FOR UPDATE;"); err != nil {
 				return err

+ 4 - 3
modules/module_shop_categories_act_modify.go

@@ -1,6 +1,7 @@
 package modules
 
 import (
+	"context"
 	"errors"
 
 	"golang-fave/engine/wrapper"
@@ -9,7 +10,7 @@ import (
 
 func (this *Modules) shop_ActionCategoryAdd(wrap *wrapper.Wrapper, pf_id, pf_name, pf_alias, pf_parent string) (error, int64) {
 	var lastID int64 = 0
-	return wrap.DB.Transaction(wrap.R.Context(), func(tx *wrapper.Tx) error {
+	return wrap.DB.Transaction(wrap.R.Context(), func(ctx context.Context, tx *wrapper.Tx) error {
 		// Block rows
 		if _, err := tx.Exec("SELECT id FROM shop_cats FOR UPDATE;"); err != nil {
 			return err
@@ -45,7 +46,7 @@ func (this *Modules) shop_ActionCategoryUpdate(wrap *wrapper.Wrapper, pf_id, pf_
 
 	if utils.StrToInt(pf_parent) == parentId {
 		// If parent not changed, just update category data
-		return wrap.DB.Transaction(wrap.R.Context(), func(tx *wrapper.Tx) error {
+		return wrap.DB.Transaction(wrap.R.Context(), func(ctx context.Context, tx *wrapper.Tx) error {
 			// Process
 			if _, err := tx.Exec(`
 				UPDATE shop_cats SET
@@ -68,7 +69,7 @@ func (this *Modules) shop_ActionCategoryUpdate(wrap *wrapper.Wrapper, pf_id, pf_
 	// TODO: Fix parent change
 
 	// Parent is changed, move category to new parent
-	return wrap.DB.Transaction(wrap.R.Context(), func(tx *wrapper.Tx) error {
+	return wrap.DB.Transaction(wrap.R.Context(), func(ctx context.Context, tx *wrapper.Tx) error {
 		// Block all rows
 		if _, err := tx.Exec("SELECT id FROM shop_cats FOR UPDATE;"); err != nil {
 			return err

+ 3 - 1
modules/module_shop_currencies_act_delete.go

@@ -1,6 +1,8 @@
 package modules
 
 import (
+	"context"
+
 	"golang-fave/engine/wrapper"
 	"golang-fave/utils"
 )
@@ -18,7 +20,7 @@ func (this *Modules) RegisterAction_ShopCurrenciesDelete() *Action {
 			return
 		}
 
-		err := wrap.DB.Transaction(wrap.R.Context(), func(tx *wrapper.Tx) error {
+		err := wrap.DB.Transaction(wrap.R.Context(), func(ctx context.Context, tx *wrapper.Tx) error {
 			// Process
 			if _, err := tx.Exec(
 				`DELETE FROM shop_currencies WHERE id = ?;`,

+ 4 - 2
modules/module_shop_currencies_act_modify.go

@@ -1,6 +1,8 @@
 package modules
 
 import (
+	"context"
+
 	"golang-fave/engine/wrapper"
 	"golang-fave/utils"
 )
@@ -44,7 +46,7 @@ func (this *Modules) RegisterAction_ShopCurrenciesModify() *Action {
 
 		if pf_id == "0" {
 			var lastID int64 = 0
-			if err := wrap.DB.Transaction(wrap.R.Context(), func(tx *wrapper.Tx) error {
+			if err := wrap.DB.Transaction(wrap.R.Context(), func(ctx context.Context, tx *wrapper.Tx) error {
 				// Insert row
 				res, err := tx.Exec(
 					`INSERT INTO shop_currencies SET
@@ -80,7 +82,7 @@ func (this *Modules) RegisterAction_ShopCurrenciesModify() *Action {
 
 			wrap.Write(`window.location='/cp/shop/currencies-modify/` + utils.Int64ToStr(lastID) + `/';`)
 		} else {
-			if err := wrap.DB.Transaction(wrap.R.Context(), func(tx *wrapper.Tx) error {
+			if err := wrap.DB.Transaction(wrap.R.Context(), func(ctx context.Context, tx *wrapper.Tx) error {
 				// Block rows
 				if _, err := tx.Exec("SELECT id FROM shop_currencies WHERE id = ? FOR UPDATE;", utils.StrToInt(pf_id)); err != nil {
 					return err

+ 3 - 1
modules/module_users_act_delete.go

@@ -1,6 +1,8 @@
 package modules
 
 import (
+	"context"
+
 	"golang-fave/engine/wrapper"
 	"golang-fave/utils"
 )
@@ -18,7 +20,7 @@ func (this *Modules) RegisterAction_UsersDelete() *Action {
 			return
 		}
 
-		err := wrap.DB.Transaction(wrap.R.Context(), func(tx *wrapper.Tx) error {
+		err := wrap.DB.Transaction(wrap.R.Context(), func(ctx context.Context, tx *wrapper.Tx) error {
 			// Block rows
 			if _, err := tx.Exec("SELECT id FROM blog_cats WHERE user = ? FOR UPDATE;", utils.StrToInt(pf_id)); err != nil {
 				return err

+ 5 - 3
modules/module_users_act_modify.go

@@ -1,6 +1,8 @@
 package modules
 
 import (
+	"context"
+
 	"golang-fave/engine/wrapper"
 	"golang-fave/utils"
 )
@@ -57,7 +59,7 @@ func (this *Modules) RegisterAction_UsersModify() *Action {
 			}
 
 			var lastID int64 = 0
-			if err := wrap.DB.Transaction(wrap.R.Context(), func(tx *wrapper.Tx) error {
+			if err := wrap.DB.Transaction(wrap.R.Context(), func(ctx context.Context, tx *wrapper.Tx) error {
 				res, err := tx.Exec(
 					`INSERT INTO users SET
 						first_name = ?,
@@ -92,7 +94,7 @@ func (this *Modules) RegisterAction_UsersModify() *Action {
 		} else {
 			// Update user
 			if pf_password == "" {
-				if err := wrap.DB.Transaction(wrap.R.Context(), func(tx *wrapper.Tx) error {
+				if err := wrap.DB.Transaction(wrap.R.Context(), func(ctx context.Context, tx *wrapper.Tx) error {
 					_, err := tx.Exec(
 						`UPDATE users SET
 							first_name = ?,
@@ -119,7 +121,7 @@ func (this *Modules) RegisterAction_UsersModify() *Action {
 					return
 				}
 			} else {
-				if err := wrap.DB.Transaction(wrap.R.Context(), func(tx *wrapper.Tx) error {
+				if err := wrap.DB.Transaction(wrap.R.Context(), func(ctx context.Context, tx *wrapper.Tx) error {
 					_, err := tx.Exec(
 						`UPDATE users SET
 							first_name = ?,