diff options
author | sunnavy <sunnavy@bestpractical.com> | 2021-05-20 00:13:52 +0300 |
---|---|---|
committer | sunnavy <sunnavy@bestpractical.com> | 2022-10-19 00:25:59 +0300 |
commit | 34ec52115c222131c7c1957e425d996ac698512a (patch) | |
tree | 34e62cba0c856e495766eae9d6335877f32a697a | |
parent | 65e82c67ea3acada2cc99b7258dcc0c39ce8d9b6 (diff) |
Clear old data when registering the whole custom roles
RegisterRoles is used to refresh custom roles in
RT::Interface::Web::MaybeRebuildCustomRolesCache, but previously it just
updated enabled ones and wrongly ignored disabled/deleted ones.
This commit updates the logic to remove existing custom roles first and
then fill new data from scratch, which fixes the issue.
-rw-r--r-- | lib/RT/CustomRoles.pm | 5 | ||||
-rw-r--r-- | lib/RT/Record/Role/Roles.pm | 2 |
2 files changed, 6 insertions, 1 deletions
diff --git a/lib/RT/CustomRoles.pm b/lib/RT/CustomRoles.pm index 7fdecf856c..f9f01db2fa 100644 --- a/lib/RT/CustomRoles.pm +++ b/lib/RT/CustomRoles.pm @@ -98,6 +98,11 @@ subsystem, suitable for system startup. sub RegisterRoles { my $class = shift; + for my $type ( keys %RT::Record::Role::Roles::ROLES ) { + %{ $RT::Record::Role::Roles::ROLES{$type} } = map { $_ => $RT::Record::Role::Roles::ROLES{$type}{$_} } + grep { !/^RT::CustomRole-/ } keys %{$RT::Record::Role::Roles::ROLES{$type}}; + } + my $roles = $class->new(RT->SystemUser); $roles->UnLimit; diff --git a/lib/RT/Record/Role/Roles.pm b/lib/RT/Record/Role/Roles.pm index e4789e22d1..44466123d2 100644 --- a/lib/RT/Record/Role/Roles.pm +++ b/lib/RT/Record/Role/Roles.pm @@ -317,7 +317,7 @@ sub Roles { } { - my %ROLES; + our %ROLES; sub _ROLES { my $class = ref($_[0]) || $_[0]; return $ROLES{$class} ||= {}; |