From 0181e189a3dad8882b80d277476d781912807228 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Fri, 27 Apr 2012 21:37:45 +0100 Subject: modulemanager: Set module.environment before calling add_host, otherwise the module will get the parent's environment (thanks xnyhps and Maranda) --- core/modulemanager.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'core') 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 -- cgit v1.2.3