Bugzilla – Attachment 174579 Details for
Bug 38136
Refactor database translations (alternative)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 38136: Fix C4::Biblio::GetAuthorisedValueDesc for itemtypes
Bug-38136-Fix-C4BiblioGetAuthorisedValueDesc-for-i.patch (text/plain), 5.32 KB, created by
Julian Maurice
on 2024-11-15 13:26:17 UTC
(
hide
)
Description:
Bug 38136: Fix C4::Biblio::GetAuthorisedValueDesc for itemtypes
Filename:
MIME Type:
Creator:
Julian Maurice
Created:
2024-11-15 13:26:17 UTC
Size:
5.32 KB
patch
obsolete
>From 9cb2976f1d2c5c0b885ae6550d8461c4a3cd15cf Mon Sep 17 00:00:00 2001 >From: Julian Maurice <julian.maurice@biblibre.com> >Date: Fri, 15 Nov 2024 14:20:39 +0100 >Subject: [PATCH] Bug 38136: Fix C4::Biblio::GetAuthorisedValueDesc for > itemtypes > >Store itemtypes in memory cache so that we can use >translated_description, which will use the right cache >--- > C4/Biblio.pm | 19 +++++++++---------- > .../Koha/Filter/ExpandCodedFields.t | 3 ++- > t/db_dependent/Koha/Item.t | 12 ++++++++---- > 3 files changed, 19 insertions(+), 15 deletions(-) > >diff --git a/C4/Biblio.pm b/C4/Biblio.pm >index 54055aec2a..6f162e2119 100644 >--- a/C4/Biblio.pm >+++ b/C4/Biblio.pm >@@ -99,6 +99,7 @@ use C4::Linker; > use C4::OAI::Sets; > > use Koha::Logger; >+use Koha::Cache::Memory::Lite; > use Koha::Caches; > use Koha::ClassSources; > use Koha::Authority::Types; >@@ -1469,17 +1470,15 @@ sub GetAuthorisedValueDesc { > > #---- 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 ); >+ my $memory_cache = Koha::Cache::Memory::Lite->get_instance(); >+ my $cache_key = 'GetAuthorisedValueDesc:itemtypes'; >+ my $itemtypes = $memory_cache->get_from_cache($cache_key); >+ unless ($itemtypes) { >+ $itemtypes = { map { $_->itemtype => $_ } Koha::ItemTypes->as_list }; >+ $memory_cache->set_in_cache($cache_key, $itemtypes); > } >- return $itypes->{$value}; >+ my $itemtype = $itemtypes->{$value}; >+ return $itemtype ? $itemtype->translated_description : undef; > } > > if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "cn_source" ) { >diff --git a/t/db_dependent/Koha/Filter/ExpandCodedFields.t b/t/db_dependent/Koha/Filter/ExpandCodedFields.t >index ac33dc9a14..234b8cde5e 100755 >--- a/t/db_dependent/Koha/Filter/ExpandCodedFields.t >+++ b/t/db_dependent/Koha/Filter/ExpandCodedFields.t >@@ -68,10 +68,11 @@ subtest 'ExpandCodedFields tests' => sub { > $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); > >+ Koha::Caches->get_instance('localization')->clear_from_cache('Itemtype:en'); >+ > 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 9fa642be69..2875744022 100755 >--- a/t/db_dependent/Koha/Item.t >+++ b/t/db_dependent/Koha/Item.t >@@ -1934,10 +1934,11 @@ subtest 'columns_to_str' => sub { > $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::Caches->get_instance('localization')->clear_from_cache('Itemtype:en'); >+ > # Creating subfields 'é', 'è' that are not linked with a kohafield > Koha::MarcSubfieldStructures->search( > { >@@ -2018,10 +2019,11 @@ subtest 'columns_to_str' => sub { > $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::Caches->get_instance('localization')->clear_from_cache('Itemtype:en'); >+ > $schema->storage->txn_rollback; > }; > >@@ -2038,10 +2040,11 @@ subtest 'strings_map() tests' => sub { > $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::Caches->get_instance('localization')->clear_from_cache('Itemtype:en'); >+ > # Recreating subfields just to be sure tests will be ok > # 1 => av (LOST) > # 3 => no link >@@ -2224,9 +2227,10 @@ subtest 'strings_map() tests' => sub { > $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::Caches->get_instance('localization')->clear_from_cache('Itemtype:en'); >+ > $schema->storage->txn_rollback; > }; > >-- >2.39.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 38136
:
172585
|
172804
|
173195
|
173196
|
173197
|
173198
|
174578
| 174579 |
174580
|
174581
|
174598
|
174599