From 52315d60f38165195b86b49c771d1861084dc9dd Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Mon, 13 Mar 2023 16:42:26 -0300 Subject: [PATCH] Bug 33214: (follow-up) Consistency on key names This patch makes GetAuthorisedValueDesc used cache keys match what we discussed on the bug, which seems to have been lost on some rebase and highlighted by failing tests. I also add some more cache flushes. Signed-off-by: Tomas Cohen Arazi --- C4/Biblio.pm | 6 +++--- t/db_dependent/Koha/Filter/ExpandCodedFields.t | 5 +++++ t/db_dependent/Koha/Item.t | 1 + 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index e90eb117b7..1af5e12696 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -1385,7 +1385,7 @@ sub GetAuthorisedValueDesc { #---- branch if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "branches" ) { - $cache_key = "LibraryNames"; + $cache_key = "libraries:name"; my $libraries = $cache->get_from_cache( $cache_key, { unsafe => 1 } ); if ( !$libraries ) { $libraries = { @@ -1403,7 +1403,7 @@ sub GetAuthorisedValueDesc { if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "itemtypes" ) { my $lang = C4::Languages::getlanguage; $lang //= 'en'; - $cache_key = $lang . 'ItemTypeDescriptions'; + $cache_key = 'itemtype:description:' . $lang; my $itypes = $cache->get_from_cache( $cache_key, { unsafe => 1 } ); if ( !$itypes ) { $itypes = @@ -1435,7 +1435,7 @@ sub GetAuthorisedValueDesc { my $dbh = C4::Context->dbh; if ( $category ne "" ) { - $cache_key = "AVDescriptions-" . $category; + $cache_key = "AV_descriptions:" . $category; my $av_descriptions = $cache->get_from_cache( $cache_key, { unsafe => 1 } ); if ( !$av_descriptions ) { $av_descriptions = { diff --git a/t/db_dependent/Koha/Filter/ExpandCodedFields.t b/t/db_dependent/Koha/Filter/ExpandCodedFields.t index 04912a4a83..25df74bfbe 100755 --- a/t/db_dependent/Koha/Filter/ExpandCodedFields.t +++ b/t/db_dependent/Koha/Filter/ExpandCodedFields.t @@ -73,6 +73,11 @@ 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:LOST"); C4::Biblio::ModBiblio( $record, $biblio->biblionumber ); $biblio = Koha::Biblios->find( $biblio->biblionumber); diff --git a/t/db_dependent/Koha/Item.t b/t/db_dependent/Koha/Item.t index bd56d19623..d9252ef3d8 100755 --- a/t/db_dependent/Koha/Item.t +++ b/t/db_dependent/Koha/Item.t @@ -1463,6 +1463,7 @@ subtest 'strings_map() tests' => sub { $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) -- 2.39.5