diff options
author | Kim Alvefur <zash@zash.se> | 2023-07-22 15:22:54 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2023-07-22 15:22:54 +0200 |
commit | 0df158712dfc0f3c2decfc2517d6a4fadf284a9d (patch) | |
tree | 4f0204776d6d523694d672d10ae76fc85536c6e6 /plugins/mod_storage_sql.lua | |
parent | 6aa08d7c58434685183a30805d7c77e11381719e (diff) | |
download | prosody-0df158712dfc0f3c2decfc2517d6a4fadf284a9d.tar.gz prosody-0df158712dfc0f3c2decfc2517d6a4fadf284a9d.zip |
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.
Diffstat (limited to 'plugins/mod_storage_sql.lua')
-rw-r--r-- | plugins/mod_storage_sql.lua | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/plugins/mod_storage_sql.lua b/plugins/mod_storage_sql.lua index 75180e63..a1cef29c 100644 --- a/plugins/mod_storage_sql.lua +++ b/plugins/mod_storage_sql.lua @@ -61,9 +61,8 @@ local function deserialize(t, value) 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 @@ local function keyval_store_get() 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 @@ end 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() |