Software /
code /
prosody
Changeset
13241:0419de4e4db1
mod_storage_sql: Pass variables as arguments instead of upvalues
Probably a workaround for the lack of argument passing when using xpcall
in Lua 5.1, no longer relevant.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 22 Jul 2023 15:22:54 +0200 |
parents | 13240:a378937103cb |
children | 13242:0d3881bf29a8 |
files | plugins/mod_storage_sql.lua |
diffstat | 1 files changed, 5 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/mod_storage_sql.lua Sat Jul 22 14:55:27 2023 +0200 +++ b/plugins/mod_storage_sql.lua Sat Jul 22 15:22:54 2023 +0200 @@ -61,9 +61,8 @@ end local host = module.host; -local user, store; -local function keyval_store_get() +local function keyval_store_get(user, store) local haveany; local result = {}; local select_sql = [[ @@ -88,7 +87,7 @@ return result; end end -local function keyval_store_set(data) +local function keyval_store_set(data, user, store) local delete_sql = [[ DELETE FROM "prosody" WHERE "host"=? AND "user"=? AND "store"=? @@ -123,19 +122,15 @@ local keyval_store = {}; keyval_store.__index = keyval_store; function keyval_store:get(username) - user, store = username, self.store; - local ok, result = engine:transaction(keyval_store_get); + local ok, result = engine:transaction(keyval_store_get, username, self.store); if not ok then - module:log("error", "Unable to read from database %s store for %s: %s", store, username or "<host>", result); + module:log("error", "Unable to read from database %s store for %s: %s", self.store, username or "<host>", result); return nil, result; end return result; end function keyval_store:set(username, data) - user,store = username,self.store; - return engine:transaction(function() - return keyval_store_set(data); - end); + return engine:transaction(keyval_store_set, data, username, self.store); end function keyval_store:users() local ok, result = engine:transaction(function()