diff options
author | Matthew Wild <mwild1@gmail.com> | 2012-04-27 21:37:45 +0100 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2012-04-27 21:37:45 +0100 |
commit | bcd870f7d33fd43ebaef0ab50a544776d4f04505 (patch) | |
tree | cbbd9c24da20e9c342ed87e94830c3106ed54987 /core/modulemanager.lua | |
parent | 6d82c54cfd5f73de76082d80ebbc1614811e9911 (diff) | |
download | prosody-bcd870f7d33fd43ebaef0ab50a544776d4f04505.tar.gz prosody-bcd870f7d33fd43ebaef0ab50a544776d4f04505.zip |
modulemanager: Set module.environment before calling add_host, otherwise the module will get the parent's environment (thanks xnyhps and Maranda)
Diffstat (limited to 'core/modulemanager.lua')
-rw-r--r-- | core/modulemanager.lua | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/core/modulemanager.lua b/core/modulemanager.lua index bf1e1924..5a97e5bf 100644 --- a/core/modulemanager.lua +++ b/core/modulemanager.lua @@ -142,10 +142,10 @@ local function do_load_module(host, module_name) },{ __index = modulemap["*"][module_name].module; }); + local host_module = setmetatable({ module = host_module_api }, { __index = mod }); + host_module_api.environment = host_module; local ok, result, module_err = call_module_method(mod, "add_host", host_module_api); if not ok or result == false then return nil, ok and module_err or result; end - local host_module = setmetatable({ module = host_module_api }, { __index = mod }); - host_module.module.environment = host_module; modulemap[host][module_name] = host_module; return host_module; end |