# HG changeset patch
# User Matthew Wild <mwild1@gmail.com>
# Date 1335037026 -3600
# Node ID 9008fc396fb1f62a260a0521d85fa626f63f509c
# Parent  c1602c07d14dab3023bae9bd84c0ce1fbf4707ea
modulemanager: When a shared module becomes global, ensure it still gets loaded onto the original target host

diff -r c1602c07d14d -r 9008fc396fb1 core/modulemanager.lua
--- a/core/modulemanager.lua	Sat Apr 21 20:09:03 2012 +0100
+++ b/core/modulemanager.lua	Sat Apr 21 20:37:06 2012 +0100
@@ -183,8 +183,10 @@
 				log("warn", "mod_%s: Setting module.host = '*' deprecated, call module:set_global() instead", module_name);
 				api_instance:set_global();
 			end
-		else
-			modulemap[host][module_name] = pluginenv;
+			if host ~= api_instance.host and module_has_method(pluginenv, "add_host") then
+				-- Now load the module again onto the host it was originally being loaded on
+				do_load_module(host, module_name);
+			end
 		end
 	end
 	if not ok then