chore: Fix potential issues with multiple settings in helpers.load_variables

This commit is contained in:
Théophile Diot 2024-07-02 13:27:49 +01:00
parent b18bebcc7d
commit 61dc0a2fba
No known key found for this signature in database
GPG key ID: FA995104A0BA376A

View file

@ -268,12 +268,16 @@ function helpers.load_variables(all_variables, plugins)
end
if data.multiple then
for variable, value in pairs(all_variables) do
local _, server_name, multiple_setting = variable:match("((%S*_?)(" .. setting .. "_%d+))")
local multiple_setting = variable:match("^(" .. 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
variables["global"][multiple_setting] = value
end
if multisite then
for _, server_name in ipairs(server_names) do
multiple_setting = variable:match("^" .. server_name .. "_(" .. setting .. "_%d+)$")
if multiple_setting then
variables[server_name][multiple_setting] = value
end
end
end
end