Changeset

5097:d414fa8b37dc

mod_compat_roles: Fix traceback when no host roles are defined (thanks cc)
author Matthew Wild <mwild1@gmail.com>
date Tue, 29 Nov 2022 11:37:58 +0000
parents 5096:16db0a6e868c
children 5098:817bc9873fc2
files mod_compat_roles/mod_compat_roles.lua
diffstat 1 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mod_compat_roles/mod_compat_roles.lua	Tue Nov 29 11:36:28 2022 +0000
+++ b/mod_compat_roles/mod_compat_roles.lua	Tue Nov 29 11:37:58 2022 +0000
@@ -83,10 +83,15 @@
 end
 
 function moduleapi.default_permission(self, role_name, permission)
-	local r = permissions[self.host][role_name];
+	local p = permissions[self.host];
+	if not p then
+		p = {};
+		permissions[self.host] = p;
+	end
+	local r = p[role_name];
 	if not r then
 		r = {};
-		permissions[self.host][role_name] = r;
+		p[role_name] = r;
 	end
 	r[permission] = true;
 end