Fixed a hard-to-run-into bug in groups: at the time of creation of a group, the OwnerRoleID in the groups table was inconsistent with the roleID in the roles table. OpenSim core was not running into this bug, but 3rd party modules (like Wifi) were.

mb-throttle-test
Diva Canto 2014-09-21 09:22:32 -07:00
parent 519c753e46
commit 94619cba58
1 changed files with 20 additions and 12 deletions

View File

@ -150,7 +150,8 @@ namespace OpenSim.Groups
data.Data["ShowInList"] = showInList ? "1" : "0"; data.Data["ShowInList"] = showInList ? "1" : "0";
data.Data["AllowPublish"] = allowPublish ? "1" : "0"; data.Data["AllowPublish"] = allowPublish ? "1" : "0";
data.Data["MaturePublish"] = maturePublish ? "1" : "0"; data.Data["MaturePublish"] = maturePublish ? "1" : "0";
data.Data["OwnerRoleID"] = UUID.Random().ToString(); UUID roleID = UUID.Random();
data.Data["OwnerRoleID"] = roleID.ToString();
if (!m_Database.StoreGroup(data)) if (!m_Database.StoreGroup(data))
return UUID.Zero; return UUID.Zero;
@ -159,7 +160,6 @@ namespace OpenSim.Groups
_AddOrUpdateGroupRole(RequestingAgentID, data.GroupID, UUID.Zero, "Everyone", "Everyone in the group", "Member of " + name, (ulong)DefaultEveryonePowers, true); _AddOrUpdateGroupRole(RequestingAgentID, data.GroupID, UUID.Zero, "Everyone", "Everyone in the group", "Member of " + name, (ulong)DefaultEveryonePowers, true);
// Create Owner role // Create Owner role
UUID roleID = UUID.Random();
_AddOrUpdateGroupRole(RequestingAgentID, data.GroupID, roleID, "Owners", "Owners of the group", "Owner of " + name, (ulong)OwnerPowers, true); _AddOrUpdateGroupRole(RequestingAgentID, data.GroupID, roleID, "Owners", "Owners of the group", "Owner of " + name, (ulong)OwnerPowers, true);
// Add founder to group // Add founder to group
@ -247,6 +247,9 @@ namespace OpenSim.Groups
if (group == null) if (group == null)
return members; return members;
// Unfortunately this doesn't quite work on legacy group data because of a bug
// that's also being fixed here on CreateGroup. The OwnerRoleID sent to the DB was wrong.
// See how to find the ownerRoleID a few lines below.
UUID ownerRoleID = new UUID(group.Data["OwnerRoleID"]); UUID ownerRoleID = new UUID(group.Data["OwnerRoleID"]);
RoleData[] roles = m_Database.RetrieveRoles(GroupID); RoleData[] roles = m_Database.RetrieveRoles(GroupID);
@ -255,6 +258,11 @@ namespace OpenSim.Groups
return members; return members;
List<RoleData> rolesList = new List<RoleData>(roles); List<RoleData> rolesList = new List<RoleData>(roles);
// Let's find the "real" ownerRoleID
RoleData ownerRole = rolesList.Find(r => r.Data["Powers"] == ((long)OwnerPowers).ToString());
if (ownerRole != null)
ownerRoleID = ownerRole.RoleID;
// Check visibility? // Check visibility?
// When we don't want to check visibility, we pass it "all" as the requestingAgentID // When we don't want to check visibility, we pass it "all" as the requestingAgentID
bool checkVisibility = !RequestingAgentID.Equals(UUID.Zero.ToString()); bool checkVisibility = !RequestingAgentID.Equals(UUID.Zero.ToString());
@ -291,6 +299,7 @@ namespace OpenSim.Groups
{ {
m.Title = selected.Data["Title"]; m.Title = selected.Data["Title"];
m.AgentPowers = UInt64.Parse(selected.Data["Powers"]); m.AgentPowers = UInt64.Parse(selected.Data["Powers"]);
}
m.AgentID = d.PrincipalID; m.AgentID = d.PrincipalID;
m.AcceptNotices = d.Data["AcceptNotices"] == "1" ? true : false; m.AcceptNotices = d.Data["AcceptNotices"] == "1" ? true : false;
@ -302,7 +311,6 @@ namespace OpenSim.Groups
members.Add(m); members.Add(m);
} }
}
return members; return members;
} }