@@ -, +, @@ --- Koha/ClassSource.pm | 35 ++++++++++++++++++++++++++++++++++- Koha/ItemType.pm | 36 ++++++++++++++++++++++++++++++++++++ Koha/Library.pm | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 106 insertions(+), 1 deletion(-) --- a/Koha/ClassSource.pm +++ a/Koha/ClassSource.pm @@ -17,7 +17,8 @@ package Koha::ClassSource; use Modern::Perl; - +use Koha::BiblioFrameworks; +use Koha::Caches; use Koha::Database; use base qw(Koha::Object); @@ -30,8 +31,40 @@ Koha::ClassSource - Koha Classfication Source Object class =head2 Class Methods +=head3 store + +ClassSource 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->description ne $self->description ); + } + + $self = $self->SUPER::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); + } + } + + return $self; +} + =head3 _type Returns name of corresponding DBIC resultset --- a/Koha/ItemType.pm +++ a/Koha/ItemType.pm @@ -20,6 +20,8 @@ use Modern::Perl; use C4::Koha qw( getitemtypeimagelocation ); use C4::Languages; +use Koha::BiblioFrameworks; +use Koha::Caches; use Koha::Database; use Koha::CirculationRules; use Koha::Localizations; @@ -36,6 +38,40 @@ Koha::ItemType - Koha Item type Object class =cut +=head3 store + +ItemType 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->description ne $self->description ); + } + + $self = $self->SUPER::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); + } + } + + return $self; +} + =head3 image_location =cut --- a/Koha/Library.pm +++ a/Koha/Library.pm @@ -22,6 +22,8 @@ use Modern::Perl; use C4::Context; +use Koha::BiblioFrameworks; +use Koha::Caches; use Koha::Database; use Koha::StockRotationStages; use Koha::SMTP::Servers; @@ -36,6 +38,40 @@ Koha::Library - Koha Library Object class =head2 Class methods +=head3 store + +Library 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->branchname ne $self->branchname ); + } + + $self = $self->SUPER::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); + } + } + + return $self; +} + =head3 stockrotationstages my $stages = Koha::Library->stockrotationstages; --