# HG changeset patch
# User Kim Alvefur <zash@zash.se>
# Date 1651072726 -7200
# Node ID 4d36fbcdd210ba8342eff1b9d58c8c1c629d00e1
# Parent  cc84682b8429c15f9232201eca66f9a1394f3fdd
core.moduleapi: Fix 'global' property via :context() - #1748

The 'global' property should reflect whether the module API instance
represents the global context or a VirtualHost or Component context.
However the module:context() method did not override this, leading the
property of the previous module shining trough, leading to bugs in code
relying on the 'global' property.

See also #1736

diff -r cc84682b8429 -r 4d36fbcdd210 core/moduleapi.lua
--- a/core/moduleapi.lua	Mon Apr 25 15:24:56 2022 +0100
+++ b/core/moduleapi.lua	Wed Apr 27 17:18:46 2022 +0200
@@ -307,7 +307,7 @@
 
 
 function api:context(host)
-	return setmetatable({host=host or "*"}, {__index=self,__newindex=self});
+	return setmetatable({ host = host or "*", global = "*" == host }, { __index = self, __newindex = self });
 end
 
 function api:add_item(key, value)