diff options
author | Matthew Wild <mwild1@gmail.com> | 2023-12-08 14:24:49 +0000 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2023-12-08 14:24:49 +0000 |
commit | cc0f97362895d83bb8ebb96434a82df65be5ff39 (patch) | |
tree | ed53644a51771a86099cea9f2d7c00cf290584e5 /core | |
parent | c2d0d411d4e5b3b701da89d8f29cd37ea1a64bf1 (diff) | |
download | prosody-cc0f97362895d83bb8ebb96434a82df65be5ff39.tar.gz prosody-cc0f97362895d83bb8ebb96434a82df65be5ff39.zip |
configmanager: Make _G accessible via `Lua` variable, deprecate direct access
Diffstat (limited to 'core')
-rw-r--r-- | core/configmanager.lua | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/core/configmanager.lua b/core/configmanager.lua index 9a66ad13..ce787929 100644 --- a/core/configmanager.lua +++ b/core/configmanager.lua @@ -129,11 +129,22 @@ do if k:match("^ENV_") then return os.getenv(k:sub(5)); end + if k == "Lua" then + return _G; + end local val = rawget_option(config_table, env.__currenthost or "*", k); + if val ~= nil then return val; end - return rawget(_G, k); + + local g_val = rawget(_G, k); + + if g_val ~= nil then + t_insert(warnings, ("%s:%d: direct usage of the Lua API is deprecated - replace `%s` with `Lua.%s`"):format(config_file, get_line_number(config_file), k, k)); + end + + return g_val; end, __newindex = function (_, k, v) local host = env.__currenthost or "*"; |