Bugzilla – Attachment 193028 Details for
Bug 31856
Improve performance of serials subscriptions search
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 31856: Improve performance of serials subscriptions search
Bug-31856-Improve-performance-of-serials-subscript.patch (text/plain), 27.25 KB, created by
David Gustafsson
on 2026-02-12 21:23:16 UTC
(
hide
)
Description:
Bug 31856: Improve performance of serials subscriptions search
Filename:
MIME Type:
Creator:
David Gustafsson
Created:
2026-02-12 21:23:16 UTC
Size:
27.25 KB
patch
obsolete
>From c377761eff30b02bce115e045506edebb6adf2c6 Mon Sep 17 00:00:00 2001 >From: David Gustafsson <david.gustafsson@ub.gu.se> >Date: Mon, 17 Oct 2022 19:08:22 +0200 >Subject: [PATCH] Bug 31856: Improve performance of serials subscriptions > search > >To test: >1) Perform an advanced search that produces a reasonably large resultset > for serial subscriptions (preferably at least a couple of hundred) > and check the execution time. >2) Apply the patch. >3) Perform the search again, the execution should now be about one fifth > of the previous search. >4) Ensure the following tests pass: > t/db_dependent/AuthorisedValues.t > t/db_dependent/Koha/Item.t > t/db_dependent/Koha/Filter/ExpandCodedFields.t > t/db_dependent/Koha/OAI/Server/Repository.t > >Sponsored-by: Gothenburg University Library >--- > C4/Biblio.pm | 74 ++++++----------- > C4/Serials.pm | 28 +++++-- > Koha/AuthorisedValue.pm | 42 +--------- > Koha/AuthorisedValues.pm | 80 ++++++++----------- > Koha/ClassSource.pm | 44 +--------- > Koha/ClassSources.pm | 2 +- > Koha/Library.pm | 42 ---------- > Koha/Localization.pm | 36 --------- > Koha/Template/Plugin/AuthorisedValues.pm | 24 +++--- > t/db_dependent/AuthorisedValues.t | 43 +++++++--- > .../Koha/Filter/ExpandCodedFields.t | 6 -- > t/db_dependent/Koha/Item.t | 21 ++--- > t/db_dependent/Koha/OAI/Server/Repository.t | 5 -- > 13 files changed, 139 insertions(+), 308 deletions(-) > >diff --git a/C4/Biblio.pm b/C4/Biblio.pm >index 1f1f897e544..c62ca8a8201 100644 >--- a/C4/Biblio.pm >+++ b/C4/Biblio.pm >@@ -111,6 +111,7 @@ use Koha::SearchEngine::Indexer; > use Koha::SimpleMARC; > use Koha::Libraries; > use Koha::Util::MARC; >+use Koha::AuthorisedValues; > > =head1 NAME > >@@ -1498,53 +1499,37 @@ sub GetAuthorisedValueDesc { > > return q{} unless defined($value); > >- my $cache = Koha::Caches->get_instance(); >- my $cache_key; > if ( !$category ) { > > return $value unless defined $tagslib->{$tag}->{$subfield}->{'authorised_value'}; > > #---- branch > if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "branches" ) { >- $cache_key = "libraries:name"; >- my $libraries = $cache->get_from_cache( $cache_key, { unsafe => 1 } ); >- if ( !$libraries ) { >- $libraries = { >- map { $_->branchcode => $_->branchname } Koha::Libraries->search( >- {}, >- { columns => [ 'branchcode', 'branchname' ] } >- )->as_list >- }; >- $cache->set_in_cache( $cache_key, $libraries ); >- } >+ my $libraries = { >+ map { $_->branchcode => $_->branchname } Koha::Libraries->search( >+ {}, >+ { columns => [ 'branchcode', 'branchname' ] } >+ )->as_list >+ }; > return $libraries->{$value}; > } > > #---- itemtypes > if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "itemtypes" ) { >- my $lang = C4::Languages::getlanguage; >- $lang //= 'en'; >- $cache_key = 'itemtype:description:' . $lang; >- my $itypes = $cache->get_from_cache( $cache_key, { unsafe => 1 } ); >- if ( !$itypes ) { >- $itypes = { map { $_->itemtype => $_->translated_description } Koha::ItemTypes->search()->as_list }; >- $cache->set_in_cache( $cache_key, $itypes ); >+ foreach my $item_type ( Koha::ItemTypes->search()->as_list ) { >+ if ( $item_type->itemtype eq $value ) { >+ return $item_type->translated_description; >+ } > } >- return $itypes->{$value}; > } > > if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "cn_source" ) { >- $cache_key = "cn_sources:description"; >- my $cn_sources = $cache->get_from_cache( $cache_key, { unsafe => 1 } ); >- if ( !$cn_sources ) { >- $cn_sources = { >- map { $_->cn_source => $_->description } Koha::ClassSources->search( >- {}, >- { columns => [ 'cn_source', 'description' ] } >- )->as_list >- }; >- $cache->set_in_cache( $cache_key, $cn_sources ); >- } >+ my $cn_sources = { >+ map { $_->cn_source => $_->description } Koha::ClassSources->search( >+ {}, >+ { columns => [ 'cn_source', 'description' ] } >+ )->as_list >+ }; > return $cn_sources->{$value}; > } > >@@ -1552,23 +1537,14 @@ sub GetAuthorisedValueDesc { > $category = $tagslib->{$tag}->{$subfield}->{'authorised_value'}; > } > >- my $dbh = C4::Context->dbh; >- if ( $category ne "" ) { >- $cache_key = "AV_descriptions:" . $category; >- my $av_descriptions = $cache->get_from_cache( $cache_key, { unsafe => 1 } ); >- if ( !$av_descriptions ) { >- $av_descriptions = { >- map { $_->authorised_value => { lib => $_->lib, lib_opac => $_->lib_opac } } >- Koha::AuthorisedValues->search( >- { category => $category }, >- { columns => [ 'authorised_value', 'lib_opac', 'lib' ] } >- )->as_list >- }; >- $cache->set_in_cache( $cache_key, $av_descriptions ); >- } >- return ( $opac && $av_descriptions->{$value}->{'lib_opac'} ) >- ? $av_descriptions->{$value}->{'lib_opac'} >- : $av_descriptions->{$value}->{'lib'}; >+ if ( $category ) { >+ my $description = Koha::AuthorisedValues->get_description_by_category_and_authorised_value( >+ { >+ category => $category, >+ authorised_value => $value >+ } >+ ); >+ return $opac ? $description->{'opac_description'} : $description->{'lib'}; > } else { > return $value; # if nothing is found return the original value > } >diff --git a/C4/Serials.pm b/C4/Serials.pm >index 0e9d0341da2..6c3bcd3f2d0 100644 >--- a/C4/Serials.pm >+++ b/C4/Serials.pm >@@ -75,6 +75,7 @@ use C4::Context; > use C4::Log qw( logaction ); # logaction > use C4::Serials::Frequency qw( GetSubscriptionFrequency ); > use C4::Serials::Numberpattern; >+use Koha::AdditionalFields; > use Koha::AdditionalFieldValues; > use Koha::Biblios; > use Koha::DateUtils qw( dt_from_string ); >@@ -639,13 +640,28 @@ sub SearchSubscriptions { > if ( $params->{results_limit} && $total_results > $params->{results_limit} ) { > $results = [ splice( @{$results}, 0, $params->{results_limit} ) ]; > } >+ my @additional_field_ids = map { $_->id } Koha::AdditionalFields->search( { tablename => 'subscription' } )->as_list; >+ if (@additional_field_ids) { >+ my %subscriptions_by_id = map { $_->{subscriptionid } => $_ } @{$results}; >+ my $field_values_rs = Koha::AdditionalFieldValues->search( >+ { >+ field_id => { -in => \@additional_field_ids }, >+ record_id => { -in => [ keys %subscriptions_by_id ] } >+ } >+ ); >+ while (my $field_value = $field_values_rs->next) { >+ $subscriptions_by_id{$field_value->record_id}->{additional_field_values}->{$field_value->field_id} = $field_value->value; >+ } >+ } >+ else { >+ for my $subscription ( @{$results} ) { >+ $subscription->{additional_field_values} = {}; >+ } >+ } > >- for my $subscription (@$results) { >- $subscription->{cannotedit} = not can_edit_subscription($subscription); >- $subscription->{cannotdisplay} = not can_show_subscription($subscription); >- >- my $subscription_object = Koha::Subscriptions->find( $subscription->{subscriptionid} ); >- $subscription->{additional_field_values} = $subscription_object->get_additional_field_values_for_template; >+ for my $subscription ( @{$results} ) { >+ $subscription->{cannotedit} = not can_edit_subscription( $subscription ); >+ $subscription->{cannotdisplay} = not can_show_subscription( $subscription ); > } > > return wantarray ? @{$results} : { results => $results, total => $total_results }; >diff --git a/Koha/AuthorisedValue.pm b/Koha/AuthorisedValue.pm >index d52110504bb..deaa1749493 100644 >--- a/Koha/AuthorisedValue.pm >+++ b/Koha/AuthorisedValue.pm >@@ -25,13 +25,11 @@ use Koha::Exceptions; > use Koha::Object; > use Koha::Object::Limit::Library; > >-use base qw(Koha::Object Koha::Object::Limit::Library); >+use base qw(Koha::Object::CachedExpiration Koha::Object::Limit::Library); > > use constant NUM_PATTERN => q{^(-[1-9][0-9]*|0|[1-9][0-9]*)$}; > use constant NUM_PATTERN_JS => q{(-[1-9][0-9]*|0|[1-9][0-9]*)}; # ^ and $ removed > >-my $cache = Koha::Caches->get_instance(); >- > =head1 NAME > > Koha::AuthorisedValue - Koha Authorised value Object class >@@ -50,44 +48,8 @@ AuthorisedValue specific store to ensure relevant caches are flushed on change > > sub store { > my ($self) = @_; >- >- my $flush = 0; >- >- if ( !$self->in_storage ) { >- $flush = 1; >- } else { >- my %updated_columns = $self->_result->get_dirty_columns; >- >- if ( exists $updated_columns{lib} >- or exists $updated_columns{lib_opac} ) >- { >- $flush = 1; >- } >- } >- > $self->_check_is_integer_only; >- >- $self = $self->SUPER::store; >- >- if ($flush) { >- my $key = "AV_descriptions:" . $self->category; >- $cache->clear_from_cache($key); >- } >- >- return $self; >-} >- >-=head2 delete >- >-AuthorisedValue specific C<delete> to clear relevant caches on delete. >- >-=cut >- >-sub delete { >- my $self = shift @_; >- my $key = "AV_descriptions:" . $self->category; >- $cache->clear_from_cache($key); >- $self->SUPER::delete(@_); >+ return $self->SUPER::store; > } > > =head3 opac_description >diff --git a/Koha/AuthorisedValues.pm b/Koha/AuthorisedValues.pm >index bce30ff5268..845f74f1c57 100644 >--- a/Koha/AuthorisedValues.pm >+++ b/Koha/AuthorisedValues.pm >@@ -23,9 +23,8 @@ use Koha::Database; > > use Koha::AuthorisedValue; > use Koha::MarcSubfieldStructures; >-use Koha::Cache::Memory::Lite; > >-use base qw(Koha::Objects Koha::Objects::Limit::Library); >+use base qw(Koha::Objects::Cached Koha::Objects::Limit::Library); > > =head1 NAME > >@@ -115,7 +114,7 @@ sub find_by_koha_field { > distinct => 1, > } > ); >- return $av->count ? $av->next : undef; >+ return $av->next; > } > > =head2 get_description_by_koha_field >@@ -126,25 +125,12 @@ Missing POD for get_description_by_koha_field. > > sub get_description_by_koha_field { > my ( $self, $params ) = @_; >- my $frameworkcode = $params->{frameworkcode} || ''; >- my $kohafield = $params->{kohafield}; >- my $authorised_value = $params->{authorised_value}; >+ $params->{frameworkcode} //= ''; > >- return {} unless defined $authorised_value; >- >- my $memory_cache = Koha::Cache::Memory::Lite->get_instance; >- my $cache_key = "AV_descriptions:$frameworkcode:$kohafield:$authorised_value"; >- my $cached = $memory_cache->get_from_cache($cache_key); >- return $cached if $cached; >+ return {} unless defined $params->{authorised_value}; > > my $av = $self->find_by_koha_field($params); >- if ( !defined $av ) { >- $memory_cache->set_in_cache( $cache_key, {} ); >- return {}; >- } >- my $descriptions = { lib => $av->lib, opac_description => $av->opac_description }; >- $memory_cache->set_in_cache( $cache_key, $descriptions ); >- return $descriptions; >+ return defined $av ? { lib => $av->lib, opac_description => $av->opac_description } : {}; > } > > =head2 get_descriptions_by_koha_field >@@ -155,24 +141,38 @@ Missing POD for get_descriptions_by_koha_field. > > sub get_descriptions_by_koha_field { > my ( $self, $params ) = @_; >- my $frameworkcode = $params->{frameworkcode} || ''; >- my $kohafield = $params->{kohafield}; >- >- my $memory_cache = Koha::Cache::Memory::Lite->get_instance; >- my $cache_key = "AV_descriptions:$frameworkcode:$kohafield"; >- my $cached = $memory_cache->get_from_cache($cache_key); >- return @$cached if $cached; >+ $params->{frameworkcode} //= ''; > > my @avs = $self->search_by_koha_field($params)->as_list; >- my @descriptions = map { >+ my $descriptions = [ >+ map { >+ { >+ authorised_value => $_->authorised_value, >+ lib => $_->lib, >+ opac_description => $_->opac_description >+ } >+ } @avs >+ ]; >+ return @{$descriptions}; >+} >+ >+sub get_description_by_category_and_authorised_value { >+ my ( $self, $params ) = @_; >+ return unless defined $params->{category} and defined $params->{authorised_value}; >+ >+ my $av = $self->search( > { >- authorised_value => $_->authorised_value, >- lib => $_->lib, >- opac_description => $_->opac_description >+ category => $params->{category}, >+ authorised_value => $params->{authorised_value}, > } >- } @avs; >- $memory_cache->set_in_cache( $cache_key, \@descriptions ); >- return @descriptions; >+ )->next; >+ >+ return $av >+ ? { >+ lib => $av->lib, >+ opac_description => $av->opac_description >+ } >+ : {}; > } > > =head3 get_descriptions_by_marc_field >@@ -183,27 +183,15 @@ sub get_descriptions_by_koha_field { > > sub get_descriptions_by_marc_field { > my ( $self, $params ) = @_; >- my $frameworkcode = $params->{frameworkcode} || ''; >- my $tagfield = $params->{tagfield}; >- my $tagsubfield = $params->{tagsubfield}; >+ $params->{frameworkcode} //= ''; > > return {} unless defined $params->{tagfield}; > >- my $memory_cache = Koha::Cache::Memory::Lite->get_instance; >- my $cache_key = "AV_descriptions_by_MARC:$frameworkcode:$tagfield"; >- if ($tagsubfield) { >- $cache_key .= ":$tagsubfield"; >- } >- >- my $cached = $memory_cache->get_from_cache($cache_key); >- return $cached if $cached; >- > my $descriptions = {}; > my @avs = $self->search_by_marc_field($params)->as_list; > foreach my $av (@avs) { > $descriptions->{ $av->authorised_value } = $av->lib; > } >- $memory_cache->set_in_cache( $cache_key, $descriptions ); > return $descriptions; > } > >diff --git a/Koha/ClassSource.pm b/Koha/ClassSource.pm >index 3e6a5e23e50..049d3d61969 100644 >--- a/Koha/ClassSource.pm >+++ b/Koha/ClassSource.pm >@@ -17,12 +17,9 @@ package Koha::ClassSource; > > use Modern::Perl; > >-use Koha::Caches; > use Koha::Database; > >-use base qw(Koha::Object); >- >-my $cache = Koha::Caches->get_instance(); >+use base qw(Koha::Object::CachedExpiration); > > =head1 NAME > >@@ -32,45 +29,6 @@ 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) { >- $cache->clear_from_cache('cn_sources:description'); >- } >- >- return $self; >-} >- >-=head2 delete >- >-ClassSource specific C<delete> to clear relevant caches on delete. >- >-=cut >- >-sub delete { >- my $self = shift @_; >- $cache->clear_from_cache('cn_sources:description'); >- $self->SUPER::delete(@_); >-} >- > =head3 _type > > Returns name of corresponding DBIC resultset >diff --git a/Koha/ClassSources.pm b/Koha/ClassSources.pm >index faec43853b1..8cecefe0912 100644 >--- a/Koha/ClassSources.pm >+++ b/Koha/ClassSources.pm >@@ -21,7 +21,7 @@ use Koha::Database; > > use Koha::ClassSource; > >-use base qw(Koha::Objects); >+use base qw(Koha::Objects::Cached); > > =head1 NAME > >diff --git a/Koha/Library.pm b/Koha/Library.pm >index f6792fb0fbf..6936bca307e 100644 >--- a/Koha/Library.pm >+++ b/Koha/Library.pm >@@ -21,7 +21,6 @@ use Modern::Perl; > > use C4::Context; > >-use Koha::Caches; > use Koha::Database; > use Koha::Desks; > use Koha::StockRotationStages; >@@ -30,8 +29,6 @@ use Koha::Library::Hours; > > use base qw(Koha::Object::Mixin::AdditionalFields Koha::Object::CachedExpiration); > >-my $cache = Koha::Caches->get_instance(); >- > =head1 NAME > > Koha::Library - Koha Library Object class >@@ -40,45 +37,6 @@ 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) { >- $cache->clear_from_cache('libraries:name'); >- } >- >- return $self; >-} >- >-=head2 delete >- >-Library specific C<delete> to clear relevant caches on delete. >- >-=cut >- >-sub delete { >- my $self = shift @_; >- $cache->clear_from_cache('libraries:name'); >- $self->SUPER::delete(@_); >-} >- > =head3 stockrotationstages > > my $stages = Koha::Library->stockrotationstages; >diff --git a/Koha/Localization.pm b/Koha/Localization.pm >index 269e1d3b36b..c0a6e83d6ca 100644 >--- a/Koha/Localization.pm >+++ b/Koha/Localization.pm >@@ -21,9 +21,6 @@ use Koha::Database; > > use base qw(Koha::Object); > >-use Koha::Caches; >-my $cache = Koha::Caches->get_instance(); >- > =head1 NAME > > Koha::Localization - Koha Localization type Object class >@@ -34,39 +31,6 @@ Koha::Localization - Koha Localization type Object class > > =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 $key = "itemtype:description:" . $self->lang; >- $cache->clear_from_cache($key); >- } >- >- return $self; >-} >- >-=head2 delete >- >-Localization specific C<delete> to clear relevant caches on delete. >- >-=cut >- >-sub delete { >- my $self = shift @_; >- if ( $self->entity eq 'itemtypes' ) { >- my $key = "itemtype:description:" . $self->lang; >- $cache->clear_from_cache($key); >- } >- $self->SUPER::delete(@_); >-} >- > sub _type { > return 'Localization'; > } >diff --git a/Koha/Template/Plugin/AuthorisedValues.pm b/Koha/Template/Plugin/AuthorisedValues.pm >index d6508da02e8..3877353ee14 100644 >--- a/Koha/Template/Plugin/AuthorisedValues.pm >+++ b/Koha/Template/Plugin/AuthorisedValues.pm >@@ -26,18 +26,24 @@ use Koha::AuthorisedValues; > > sub GetByCode { > my ( $self, $category, $code, $opac ) = @_; >- my $av = Koha::AuthorisedValues->search( { category => $category, authorised_value => $code } ); >- return >- $av->count >- ? $opac >- ? $av->next->opac_description >- : $av->next->lib >- : $code; >+ my $av = Koha::AuthorisedValues->get_description_by_category_and_authorised_value( >+ { >+ category => $category, >+ authorised_value => $code >+ } >+ ); >+ >+ my $description; >+ if ($av) { >+ $description = $opac ? $av->{opac_description} : $av->{lib}; >+ } >+ >+ return $description || $code; > } > > sub Get { >- my ( $self, $category, $selected, $opac ) = @_; >- return GetAuthorisedValues( $category, $selected, $opac ); >+ my ( $self, $category, $opac ) = @_; >+ return GetAuthorisedValues( $category, $opac ); > } > > sub GetAuthValueDropbox { >diff --git a/t/db_dependent/AuthorisedValues.t b/t/db_dependent/AuthorisedValues.t >index 069614504ab..5a45177c18c 100755 >--- a/t/db_dependent/AuthorisedValues.t >+++ b/t/db_dependent/AuthorisedValues.t >@@ -154,7 +154,7 @@ is_deeply( > ); > > subtest 'search_by_*_field + find_by_koha_field + get_description + authorised_values' => sub { >- plan tests => 7; >+ plan tests => 8; > > my $test_cat = Koha::AuthorisedValueCategories->find('TEST'); > $test_cat->delete if $test_cat; >@@ -301,6 +301,7 @@ subtest 'search_by_*_field + find_by_koha_field + get_description + authorised_v > subtest 'get_descriptions_by_marc_field' => sub { > plan tests => 4; > >+ Koha::AuthorisedValues->_objects_cache_clear(); > my $control_descriptions = > Koha::AuthorisedValues->get_descriptions_by_marc_field( { frameworkcode => '', tagfield => '003', } ); > is_deeply( >@@ -311,18 +312,19 @@ subtest 'search_by_*_field + find_by_koha_field + get_description + authorised_v > }, > ); > >- my $control_descriptions_cached = >- Koha::AuthorisedValues->get_descriptions_by_marc_field( { frameworkcode => '', tagfield => '003', } ); >- >+ # Trigger cache >+ Koha::AuthorisedValues->get_descriptions_by_marc_field( { frameworkcode => '', tagfield => '003', } ); >+ my $bucket = Koha::AuthorisedValues->_objects_cache_bucket('args'); > is( >- "$control_descriptions", "$control_descriptions_cached", >- "Same memory address used proves cached control desc data" >+ scalar( keys %{$control_descriptions} ), ( values %{$bucket} )[0]->count, >+ "Same number of cached descriptions as control descriptions" > ); > >- my $descriptions = Koha::AuthorisedValues->get_descriptions_by_marc_field( >+ Koha::AuthorisedValues->_objects_cache_clear(); >+ $control_descriptions = Koha::AuthorisedValues->get_descriptions_by_marc_field( > { frameworkcode => '', tagfield => '952', tagsubfield => 'c' } ); > is_deeply( >- $descriptions, >+ $control_descriptions, > { > 'location_1' => 'location_1', > 'location_2' => 'location_2', >@@ -330,9 +332,13 @@ subtest 'search_by_*_field + find_by_koha_field + get_description + authorised_v > }, > ); > >- my $descriptions_cached = Koha::AuthorisedValues->get_descriptions_by_marc_field( >+ Koha::AuthorisedValues->get_descriptions_by_marc_field( > { frameworkcode => '', tagfield => '952', tagsubfield => 'c' } ); >- is( "$descriptions", "$descriptions_cached", "Same memory address used proves cached desc data" ); >+ $bucket = Koha::AuthorisedValues->_objects_cache_bucket('args'); >+ is( >+ scalar( keys %{$control_descriptions} ), ( values %{$bucket} )[0]->count, >+ "Same number of cached descriptions as control descriptions" >+ ); > }; > > subtest 'authorised_values' => sub { >@@ -363,6 +369,23 @@ subtest 'search_by_*_field + find_by_koha_field + get_description + authorised_v > > $schema->storage->txn_rollback; > }; >+ >+ subtest 'get_description_by_category_and_authorised_value' => sub { >+ plan tests => 1; >+ my $description = Koha::AuthorisedValues->get_description_by_category_and_authorised_value( >+ { >+ category => $av_0->category, >+ authorised_value => $av_0->authorised_value, >+ } >+ ); >+ is_deeply( >+ $description, >+ { >+ lib => $av_0->lib, >+ opac_description => $av_0->lib_opac >+ } >+ ); >+ }; > }; > > subtest 'is_integer_only' => sub { >diff --git a/t/db_dependent/Koha/Filter/ExpandCodedFields.t b/t/db_dependent/Koha/Filter/ExpandCodedFields.t >index e2ed0524a57..a928e9e30ad 100755 >--- a/t/db_dependent/Koha/Filter/ExpandCodedFields.t >+++ b/t/db_dependent/Koha/Filter/ExpandCodedFields.t >@@ -69,12 +69,6 @@ subtest 'ExpandCodedFields tests' => sub { > my $cache = Koha::Caches->get_instance; > $cache->clear_from_cache("MarcCodedFields-"); > >- # Clear GetAuthorisedValueDesc-generated cache >- $cache->clear_from_cache("libraries:name"); >- $cache->clear_from_cache("itemtype:description:en"); >- $cache->clear_from_cache("cn_sources:description"); >- $cache->clear_from_cache( "AV_descriptions:" . $av->category ); >- > C4::Biblio::ModBiblio( $record, $biblio->biblionumber ); > $biblio = Koha::Biblios->find( $biblio->biblionumber ); > $record = $biblio->metadata->record; >diff --git a/t/db_dependent/Koha/Item.t b/t/db_dependent/Koha/Item.t >index e0405a6a265..c72ac945cb1 100755 >--- a/t/db_dependent/Koha/Item.t >+++ b/t/db_dependent/Koha/Item.t >@@ -2454,10 +2454,6 @@ subtest 'columns_to_str' => sub { > $cache->clear_from_cache("MarcStructure-0-"); > $cache->clear_from_cache("MarcStructure-1-"); > $cache->clear_from_cache("MarcSubfieldStructure-"); >- $cache->clear_from_cache("libraries:name"); >- $cache->clear_from_cache("itemtype:description:en"); >- $cache->clear_from_cache("cn_sources:description"); >- $cache->clear_from_cache("AV_descriptions:LOST"); > > # Creating subfields 'é', 'è' that are not linked with a kohafield > Koha::MarcSubfieldStructures->search( >@@ -2539,10 +2535,9 @@ subtest 'columns_to_str' => sub { > $cache->clear_from_cache("MarcStructure-0-"); > $cache->clear_from_cache("MarcStructure-1-"); > $cache->clear_from_cache("MarcSubfieldStructure-"); >- $cache->clear_from_cache("libraries:name"); >- $cache->clear_from_cache("itemtype:description:en"); >- $cache->clear_from_cache("cn_sources:description"); >- $cache->clear_from_cache("AV_descriptions:LOST"); >+ >+ Koha::Libraries->_objects_cache_clear(); >+ Koha::ItemTypes->_objects_cache_clear(); > > $schema->storage->txn_rollback; > }; >@@ -2559,10 +2554,6 @@ subtest 'strings_map() tests' => sub { > $cache->clear_from_cache("MarcStructure-0-"); > $cache->clear_from_cache("MarcStructure-1-"); > $cache->clear_from_cache("MarcSubfieldStructure-"); >- $cache->clear_from_cache("libraries:name"); >- $cache->clear_from_cache("itemtype:description:en"); >- $cache->clear_from_cache("cn_sources:description"); >- $cache->clear_from_cache("AV_descriptions:LOST"); > > # Recreating subfields just to be sure tests will be ok > # 1 => av (LOST) >@@ -2746,9 +2737,9 @@ subtest 'strings_map() tests' => sub { > $cache->clear_from_cache("MarcStructure-0-"); > $cache->clear_from_cache("MarcStructure-1-"); > $cache->clear_from_cache("MarcSubfieldStructure-"); >- $cache->clear_from_cache("libraries:name"); >- $cache->clear_from_cache("itemtype:description:en"); >- $cache->clear_from_cache("cn_sources:description"); >+ >+ Koha::Libraries->_objects_cache_clear(); >+ Koha::ItemTypes->_objects_cache_clear(); > > $schema->storage->txn_rollback; > }; >diff --git a/t/db_dependent/Koha/OAI/Server/Repository.t b/t/db_dependent/Koha/OAI/Server/Repository.t >index ca4c70568da..ea0f6049e91 100755 >--- a/t/db_dependent/Koha/OAI/Server/Repository.t >+++ b/t/db_dependent/Koha/OAI/Server/Repository.t >@@ -53,11 +53,6 @@ subtest 'get_biblio_marcxml() tests' => sub { > my $cache = Koha::Caches->get_instance; > $cache->clear_from_cache("MarcCodedFields-"); > >- # Clear GetAuthorisedValueDesc-generated cache >- $cache->clear_from_cache("libraries:name"); >- $cache->clear_from_cache("itemtype:description:en"); >- $cache->clear_from_cache("cn_sources:description"); >- > my $cgi = Test::MockModule->new('CGI'); > $cgi->mock( 'Vars', sub { ( 'verb', 'Identify' ); } ); > my $yaml = Test::MockModule->new('YAML::XS'); >-- >2.51.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 31856
:
142058
|
142156
|
142157
|
150651
|
150652
|
150653
|
151077
|
151078
|
177383
|
177384
|
177385
|
177386
|
177387
|
177482
|
177483
|
177484
|
177485
|
177486
|
177487
|
177509
|
177510
|
177511
|
177512
|
177514
|
192967
|
192968
|
192977
|
192978
| 193028 |
193030
|
193031
|
193032