Fix shinanigans with both multiple and global settings not being stored correctly in datastore

This commit is contained in:
Théophile Diot 2023-09-07 11:00:55 +02:00
parent 8cafded894
commit 9535c04142
No known key found for this signature in database
GPG key ID: 248FEA4BAE400D06

View file

@ -236,6 +236,18 @@ function helpers.load_variables(all_variables, plugins)
if all_variables[setting] then
variables["global"][setting] = all_variables[setting]
end
if data.multiple then
for variable, value in pairs(all_variables) do
local _, server_name, multiple_setting = variable:match("((%S*_?)(" .. setting .. "_%d+))")
if multiple_setting then
if multisite and server_name and server_name:match("%S+_$") then
variables[server_name:sub(1, -2)][multiple_setting] = value
else
variables["global"][multiple_setting] = value
end
end
end
end
if multisite then
for i, server_name in ipairs(server_names) do
local key = server_name .. "_" .. setting
@ -244,17 +256,6 @@ function helpers.load_variables(all_variables, plugins)
end
end
end
if data.multiple then
for variable, value in pairs(all_variables) do
local _, server_name, multiple_setting = variable:match("((%S*)_)(" .. setting .. "_%d+)")
if multiple_setting then
if multisite and server_name and server_name ~= "" then
variables[server_name][multiple_setting] = value
end
variables["global"][multiple_setting] = value
end
end
end
end
return true, variables
end