Correctly merge tables when copying levels from one to another

This commit is contained in:
Timo Smit 2019-01-30 15:44:03 +01:00
parent d5f051890a
commit 2d349919d0
2 changed files with 13 additions and 2 deletions

View file

@ -126,7 +126,7 @@ end
function acl.copyLevelPermissions(levelId, newLevelId)
db.copyLevelPermissions(levelId, newLevelId)
cachedLevels[newLevelId] = tables.copy(cachedLevels[levelId])
cachedLevels[newLevelId] = tables.merge(cachedLevels[newLevelId], cachedLevels[levelId])
end
function acl.removeLevelPermissions(levelId)

View file

@ -19,8 +19,19 @@ local util = wolfa_requireModule("util.util")
local tables = {}
function tables.merge(tbl1, tbl2)
util.typecheck("tables.merge", {tbl1}, {"table"})
util.typecheck("tables.merge", {tbl2}, {"table"})
for key, value in pairs(tbl2) do
tbl1[key] = value
end
return tbl1
end
function tables.copy(tbl)
util.typecheck("tables.contains", {tbl}, {"table"})
util.typecheck("tables.copy", {tbl}, {"table"})
local copy = {}