@@ -, +, @@ --- C4/Biblio.pm | 2 +- Koha/AuthorisedValue.pm | 33 ++++++++++++++++++- Koha/ClassSource.pm | 7 +--- Koha/ItemType.pm | 8 ++--- Koha/Library.pm | 7 +--- Koha/Localization.pm | 29 ++++++++++++++++ admin/biblio_framework.pl | 2 ++ admin/marc_subfields_structure.pl | 2 ++ admin/marctagstructure.pl | 2 ++ .../Koha/Filter/ExpandAuthorizedValues.t | 2 +- 10 files changed, 73 insertions(+), 21 deletions(-) --- a/C4/Biblio.pm +++ a/C4/Biblio.pm @@ -1523,7 +1523,7 @@ sub GetAuthorisedValueDesc { my $dbh = C4::Context->dbh; if ( $category ne "" ) { - $cache_key = "AVDescriptions"; + $cache_key = "AVDescriptions-" . $category; my $av_descriptions = $cache->get_from_cache( $cache_key, { unsafe => 1 } ); if ( !$av_descriptions ) { $av_descriptions = { --- a/Koha/AuthorisedValue.pm +++ a/Koha/AuthorisedValue.pm @@ -19,7 +19,7 @@ package Koha::AuthorisedValue; use Modern::Perl; - +use Koha::Caches; use Koha::Database; use base qw(Koha::Object Koha::Object::Limit::Library); @@ -34,6 +34,37 @@ Koha::AuthorisedValue - Koha Authorised value Object class =cut +=head3 store + +AuthorisedValue specific store to ensure relevant caches are flushed on change + +=cut + +sub store { + my ($self) = @_; + + my $flush = 0; + + if ( !$self->in_storage ) { + $flush = 1; + } + else { + my $self_from_storage = $self->get_from_storage; + $flush = 1 if ( $self_from_storage->lib ne $self->lib ); + $flush = 1 if ( $self_from_storage->lib_opac ne $self->lib_opac ); + } + + $self = $self->SUPER::store; + + if ($flush) { + my $cache = Koha::Caches->get_instance(); + my $key = "AVDescriptions-".$self->category; + $cache->clear_from_cache($key); + } + + return $self; +} + =head3 opac_description my $description = $av->opac_description(); --- a/Koha/ClassSource.pm +++ a/Koha/ClassSource.pm @@ -54,12 +54,7 @@ sub store { if ($flush) { my $cache = Koha::Caches->get_instance(); - my @frameworks = - Koha::BiblioFrameworks->search()->get_column('frameworkcode'); - for my $frameworkcode (@frameworks) { - my $key = "MarcAVStructure-$frameworkcode"; - $cache->clear_from_cache($key); - } + $cache->clear_from_cache('ClassSources'); } return $self; --- a/Koha/ItemType.pm +++ a/Koha/ItemType.pm @@ -61,12 +61,8 @@ sub store { if ($flush) { my $cache = Koha::Caches->get_instance(); - my @frameworks = - Koha::BiblioFrameworks->search()->get_column('frameworkcode'); - for my $frameworkcode (@frameworks) { - my $key = "MarcAVStructure-$frameworkcode"; - $cache->clear_from_cache($key); - } + my $key = "enItemTypeDescriptions"; + $cache->clear_from_cache($key); } return $self; --- a/Koha/Library.pm +++ a/Koha/Library.pm @@ -61,12 +61,7 @@ sub store { if ($flush) { my $cache = Koha::Caches->get_instance(); - my @frameworks = - Koha::BiblioFrameworks->search()->get_column('frameworkcode'); - for my $frameworkcode (@frameworks) { - my $key = "MarcAVStructure-$frameworkcode"; - $cache->clear_from_cache($key); - } + $cache->clear_from_cache('LibraryNames'); } return $self; --- a/Koha/Localization.pm +++ a/Koha/Localization.pm @@ -21,6 +21,35 @@ use Koha::Database; use base qw(Koha::Object); +=head1 NAME + +Koha::Localization - Koha Localization type Object class + +=head1 API + +=head2 Class methods + +=cut + +=head3 store + +Localization specific store to ensure relevant caches are flushed on change + +=cut + +sub store { + my ($self) = @_; + $self = $self->SUPER::store; + + if ($self->entity eq 'itemtypes') { + my $cache = Koha::Caches->get_instance(); + my $key = $self->lang."ItemTypeDescriptions"; + $cache->clear_from_cache($key); + } + + return $self; +} + sub _type { return 'Localization'; } --- a/admin/biblio_framework.pl +++ a/admin/biblio_framework.pl @@ -80,6 +80,7 @@ if ( $op eq 'add_form' ) { $cache->clear_from_cache("MarcStructure-1-$frameworkcode"); $cache->clear_from_cache("default_value_for_mod_marc-"); $cache->clear_from_cache("MarcSubfieldStructure-$frameworkcode"); + $cache->clear_from_cache("MarcCodedFields-$frameworkcode"); $op = 'list'; } elsif ( $op eq 'delete_confirm' ) { my $framework = Koha::BiblioFrameworks->find($frameworkcode); @@ -111,6 +112,7 @@ if ( $op eq 'add_form' ) { $cache->clear_from_cache("MarcStructure-1-$frameworkcode"); $cache->clear_from_cache("default_value_for_mod_marc-"); $cache->clear_from_cache("MarcSubfieldStructure-$frameworkcode"); + $cache->clear_from_cache("MarcCodedFields-$frameworkcode"); $op = 'list'; } --- a/admin/marc_subfields_structure.pl +++ a/admin/marc_subfields_structure.pl @@ -309,6 +309,7 @@ elsif ( $op eq 'add_validate' ) { $cache->clear_from_cache("MarcStructure-1-$frameworkcode"); $cache->clear_from_cache("default_value_for_mod_marc-"); $cache->clear_from_cache("MarcSubfieldStructure-$frameworkcode"); + $cache->clear_from_cache("MarcCodedFields-$frameworkcode"); print $input->redirect("/cgi-bin/koha/admin/marc_subfields_structure.pl?tagfield=$tagfield&frameworkcode=$frameworkcode"); exit; @@ -347,6 +348,7 @@ elsif ( $op eq 'delete_confirmed' ) { $cache->clear_from_cache("MarcStructure-1-$frameworkcode"); $cache->clear_from_cache("default_value_for_mod_marc-"); $cache->clear_from_cache("MarcSubfieldStructure-$frameworkcode"); + $cache->clear_from_cache("MarcCodedFields-$frameworkcode"); print $input->redirect("/cgi-bin/koha/admin/marc_subfields_structure.pl?tagfield=$tagfield&frameworkcode=$frameworkcode"); exit; --- a/admin/marctagstructure.pl +++ a/admin/marctagstructure.pl @@ -155,6 +155,7 @@ if ($op eq 'add_form') { $cache->clear_from_cache("MarcStructure-1-$frameworkcode"); $cache->clear_from_cache("default_value_for_mod_marc-"); $cache->clear_from_cache("MarcSubfieldStructure-$frameworkcode"); + $cache->clear_from_cache("MarcCodedFields-$frameworkcode"); print $input->redirect("/cgi-bin/koha/admin/marctagstructure.pl?searchfield=$tagfield&frameworkcode=$frameworkcode"); exit; # END $OP eq ADD_VALIDATE @@ -180,6 +181,7 @@ if ($op eq 'add_form') { $cache->clear_from_cache("MarcStructure-1-$frameworkcode"); $cache->clear_from_cache("default_value_for_mod_marc-"); $cache->clear_from_cache("MarcSubfieldStructure-$frameworkcode"); + $cache->clear_from_cache("MarcCodedFields-$frameworkcode"); $template->param( searchfield => $searchfield ); # END $OP eq DELETE_CONFIRMED ################## ITEMTYPE_CREATE ################################## --- a/t/db_dependent/Koha/Filter/ExpandAuthorizedValues.t +++ a/t/db_dependent/Koha/Filter/ExpandAuthorizedValues.t @@ -62,7 +62,7 @@ subtest 'ExpandAuthorizedValues tests' => sub { my $cache = Koha::Caches->get_instance; $cache->clear_from_cache("MarcStructure-0-"); $cache->clear_from_cache("MarcStructure-1-"); - $cache->clear_from_cache("MarcAVStructure-1-"); + $cache->clear_from_cache("MarcCodedFields-"); $cache->clear_from_cache("default_value_for_mod_marc-"); $cache->clear_from_cache("MarcSubfieldStructure-"); --