@@ -, +, @@ --- C4/Auth.pm | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) --- a/C4/Auth.pm +++ a/C4/Auth.pm @@ -33,6 +33,7 @@ use C4::Languages; use C4::Search::History; use Koha; use Koha::Caches; +use Koha::Cache::Memory::Lite; use Koha::AuthUtils qw(get_script_name hash_password); use Koha::Checkouts; use Koha::DateUtils qw(dt_from_string); @@ -2086,16 +2087,25 @@ of the subpermission. =cut sub get_all_subpermissions { + + my $memory_cache = Koha::Cache::Memory::Lite->get_instance(); + my $cache_key = "all_subpermissions"; + + my $cached = $memory_cache->get_from_cache($cache_key); + return $cached if $cached; + my $dbh = C4::Context->dbh; - my $sth = $dbh->prepare( "SELECT flag, code + my $permissions = $dbh->selectall_arrayref( q|SELECT flag, code FROM permissions - JOIN userflags ON (module_bit = bit)" ); - $sth->execute(); + JOIN userflags ON (module_bit = bit)|, { Slice => {} } ); my $all_perms = {}; - while ( my $perm = $sth->fetchrow_hashref ) { + for my $perm ( @$permissions ) { $all_perms->{ $perm->{'flag'} }->{ $perm->{'code'} } = 1; } + + $memory_cache->set_in_cache( $cache_key, $all_perms ); + return $all_perms; } --