Bugzilla – Attachment 150015 Details for
Bug 24975
Refactor database translations
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24975: Simplify and uniform calls to get the translation
Bug-24975-Simplify-and-uniform-calls-to-get-the-tr.patch (text/plain), 55.05 KB, created by
Jonathan Druart
on 2023-04-21 10:28:18 UTC
(
hide
)
Description:
Bug 24975: Simplify and uniform calls to get the translation
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2023-04-21 10:28:18 UTC
Size:
55.05 KB
patch
obsolete
>From 026fbcf3cec53043dedf916d0c502e69eddf8789 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Fri, 21 Apr 2023 12:20:03 +0200 >Subject: [PATCH] Bug 24975: Simplify and uniform calls to get the translation > >This patch add a caching mecanism for ItemType objects. We are also >caching the result of the image location and the translation key so that >we can retrieve from the cache and pass them to the temmplate. > >We should avoid call to db_t in the controller scripts, and prefer to >pass the itemtype object and let the template does what it needs >(retrieve the translated description, display the image) > >Note that the new Koha::Template::Plugin::ItemTypes->GetSorted should >certainly be used in other places, for instance in > * catalogue/search.pl sub prepare_adv_search_types > * opac/opac-search.pl >but those 2 occurrences are tricky and we would like to prevent >regressions (as much as possible...) > >A major change is the modification of the prototype of search_compat, I >am not sure this patch is updating all the template when the result of >the search is passed. > >Note that Koha::SearchEngine::Elasticsearch::Search could use >Koha::ItemTypes->get_from_cache, and certainly other places as well(?) >--- > C4/Biblio.pm | 25 ++++------ > C4/Items.pm | 1 - > C4/Search.pm | 37 ++++++-------- > Koha/I18N.pm | 4 +- > Koha/ItemType.pm | 30 +++++------- > Koha/ItemTypes.pm | 49 +++++++++++++++++-- > Koha/SearchEngine/Elasticsearch/Search.pm | 6 +-- > Koha/Template/Plugin/ItemTypes.pm | 24 ++++++++- > Koha/UI/Form/Builder/Item.pm | 17 ++----- > acqui/orderreceive.pl | 1 - > authorities/authorities.pl | 1 - > catalogue/detail.pl | 3 +- > catalogue/getitem-ajax.pl | 1 - > catalogue/itemsearch.pl | 1 - > catalogue/moredetail.pl | 11 ++--- > catalogue/search.pl | 22 ++++----- > cataloguing/addbiblio.pl | 1 - > cataloguing/additem.pl | 1 - > circ/transferstoreceive.pl | 1 - > .../prog/en/modules/catalogue/detail.tt | 2 +- > .../prog/en/modules/catalogue/moredetail.tt | 5 +- > .../prog/en/modules/catalogue/results.tt | 14 +++--- > .../serials/subscription-bib-search.tt | 6 +-- > .../bootstrap/en/modules/opac-detail.tt | 22 +++++---- > .../bootstrap/en/modules/opac-reserve.tt | 10 ++-- > opac/opac-detail.pl | 21 ++------ > opac/opac-reserve.pl | 13 ++--- > opac/opac-search.pl | 10 ++-- > reports/issues_stats.pl | 6 +-- > reports/reserves_stats.pl | 1 - > serials/subscription-bib-search.pl | 19 ------- > svc/checkouts | 2 +- > .../Koha/Filter/ExpandCodedFields.t | 1 - > t/db_dependent/Koha/Item.t | 4 -- > tools/batchMod.pl | 1 - > 35 files changed, 176 insertions(+), 197 deletions(-) > >diff --git a/C4/Biblio.pm b/C4/Biblio.pm >index 504d597966f..898abeb9f8a 100644 >--- a/C4/Biblio.pm >+++ b/C4/Biblio.pm >@@ -1384,15 +1384,14 @@ 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 $cache = Koha::Caches->get_instance(); >+ my $cache_key = "libraries:name"; > my $libraries = $cache->get_from_cache( $cache_key, { unsafe => 1 } ); > if ( !$libraries ) { > $libraries = { >@@ -1408,21 +1407,14 @@ 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 ); >- } >- return $itypes->{$value}; >+ my $itemtype = Koha::ItemType->get_from_cache($value); >+ # FIXME Should we raise an error if the item type does not exist? >+ return $itemtype ? db_t('itemtype', $itemtype->{translation_key}) : q{}; > } > > if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "cn_source" ) { >- $cache_key = "cn_sources:description"; >+ my $cache = Koha::Caches->get_instance(); >+ my $cache_key = "cn_sources:description"; > my $cn_sources = $cache->get_from_cache( $cache_key, { unsafe => 1 } ); > if ( !$cn_sources ) { > $cn_sources = { >@@ -1442,7 +1434,8 @@ sub GetAuthorisedValueDesc { > > my $dbh = C4::Context->dbh; > if ( $category ne "" ) { >- $cache_key = "AV_descriptions:" . $category; >+ my $cache = Koha::Caches->get_instance(); >+ my $cache_key = "AV_descriptions:" . $category; > my $av_descriptions = $cache->get_from_cache( $cache_key, { unsafe => 1 } ); > if ( !$av_descriptions ) { > $av_descriptions = { >diff --git a/C4/Items.pm b/C4/Items.pm >index 5522597e0ea..96669a9d32b 100644 >--- a/C4/Items.pm >+++ b/C4/Items.pm >@@ -61,7 +61,6 @@ use Koha::Database; > > use Koha::Biblios; > use Koha::Biblioitems; >-use Koha::I18N; > use Koha::Items; > use Koha::ItemTypes; > use Koha::SearchEngine; >diff --git a/C4/Search.pm b/C4/Search.pm >index 77e3e6e48cd..2809261bc6e 100644 >--- a/C4/Search.pm >+++ b/C4/Search.pm >@@ -284,7 +284,7 @@ sub SimpleSearch { > ( undef, $results_hashref, \@facets_loop ) = getRecords ( > > $koha_query, $simple_query, $sort_by_ref, $servers_ref, >- $results_per_page, $offset, $branches, $itemtypes, >+ $results_per_page, $offset, $branches, > $query_type, $scan, $opac > ); > >@@ -298,7 +298,7 @@ See verbose embedded documentation. > sub getRecords { > my ( > $koha_query, $simple_query, $sort_by_ref, $servers_ref, >- $results_per_page, $offset, $branches, $itemtypes, >+ $results_per_page, $offset, $branches, > $query_type, $scan, $opac > ) = @_; > >@@ -411,6 +411,9 @@ sub getRecords { > } > } # finished looping through servers > >+ my $itemtypes = Koha::ItemTypes->get_from_cache; >+ my %itemtypes = map { $_->{itemtype} => $_ } @{ $itemtypes }; >+ > # The big moment: asynchronously retrieve results from all servers > _ZOOM_event_loop( > \@zconns, >@@ -533,13 +536,8 @@ sub getRecords { > > # if it's a itemtype, label by the name, not the code, > if ( $link_value =~ /itype/ ) { >- if ( defined $itemtypes >- && ref($itemtypes) eq "HASH" >- && defined $itemtypes->{$one_facet} >- && ref( $itemtypes->{$one_facet} ) eq >- "HASH" ) >- { >- $facet_label_value = db_t('itemtype', $itemtypes->{$one_facet}->{itemtype}); >+ if ( exists $itemtypes->{$one_facet} ) { >+ $facet_label_value = db_t('itemtype', $itemtypes->{$one_facet}->{translation_key}); > } > } > >@@ -1669,8 +1667,8 @@ sub searchResults { > my $notforloan_authorised_value = $av->count ? $av->next->authorised_value : undef; > > #Get itemtype hash >- my $itemtypes = Koha::ItemTypes->search; >- my %itemtypes = map { $_->{itemtype} => $_ } @{ $itemtypes->unblessed }; >+ my $itemtypes = Koha::ItemTypes->get_from_cache; >+ my %itemtypes = map { $_->{itemtype} => $_ } @{ $itemtypes }; > > #search item field code > my ($itemtag, undef) = &GetMarcFromKohaField( "items.itemnumber" ); >@@ -1748,10 +1746,8 @@ sub searchResults { > $oldbiblio->{edition} = $oldbiblio->{editionstatement}; > > my $itemtype = $oldbiblio->{itemtype} ? $itemtypes{$oldbiblio->{itemtype}} : undef; >- # add imageurl to itemtype if there is one >- $oldbiblio->{imageurl} = $itemtype ? getitemtypeimagelocation( $search_context->{'interface'}, $itemtype->{imageurl} ) : q{}; >- # Build summary if there is one (the summary is defined in the itemtypes table) >- $oldbiblio->{description} = $itemtype ? db_t('itemtype', $itemtype->{itemtype}) : q{}; >+ >+ $oldbiblio->{itemtype} = $itemtype; > > # Pull out the items fields > my @fields = $marcrecord->field($itemtag); >@@ -1823,7 +1819,7 @@ sub searchResults { > next; > } > >- $item->{description} = db_t('itemtype', $itemtypes{ $item->{itype} }{itemtype}) if $item->{itype}; >+ $item->{itemtype} = $itemtypes{ $item->{itype} } if $item->{itype}; > > # OPAC hidden items > if ($is_opac) { >@@ -1865,9 +1861,7 @@ sub searchResults { > $onloan_items->{$key}->{branchname} = $item->{branchname}; > $onloan_items->{$key}->{location} = $shelflocations->{ $item->{location} } if $item->{location}; > $onloan_items->{$key}->{itemcallnumber} = $item->{itemcallnumber}; >- $onloan_items->{$key}->{description} = $item->{description}; >- $onloan_items->{$key}->{imageurl} = >- getitemtypeimagelocation( $search_context->{'interface'}, $itemtypes{ $item->{itype} }->{imageurl} ); >+ $onloan_items->{$key}->{itemtype} = $itemtypes{ $item->{itype} }; > > # if something's checked out and lost, mark it as 'long overdue' > if ( $item->{itemlost} ) { >@@ -1965,8 +1959,7 @@ sub searchResults { > $other_items->{$key}->{notforloan} = GetAuthorisedValueDesc('','',$item->{notforloan},'','',$notforloan_authorised_value) if $notforloan_authorised_value and $item->{notforloan}; > $other_items->{$key}->{count}++ if $item->{$hbranch}; > $other_items->{$key}->{location} = $shelflocations->{ $item->{location} } if $item->{location}; >- $other_items->{$key}->{description} = $item->{description}; >- $other_items->{$key}->{imageurl} = getitemtypeimagelocation( $search_context->{'interface'}, $itemtypes{ $item->{itype}//q{} }->{imageurl} ); >+ $other_items->{$key}->{itemtype} = $itemtypes{ $item->{itype} }; > } > # item is available > else { >@@ -1976,7 +1969,7 @@ sub searchResults { > $available_items->{$prefix}->{$_} = $item->{$_}; > } > $available_items->{$prefix}->{location} = $shelflocations->{ $item->{location} } if $item->{location}; >- $available_items->{$prefix}->{imageurl} = getitemtypeimagelocation( $search_context->{'interface'}, $itemtypes{ $item->{itype}//q{} }->{imageurl} ); >+ $available_items->{$prefix}->{itemtype} = $itemtypes{ $item->{itype} }; > } > } > } # notforloan, item level and biblioitem level >diff --git a/Koha/I18N.pm b/Koha/I18N.pm >index a5f517d6ace..9dfb175e20b 100644 >--- a/Koha/I18N.pm >+++ b/Koha/I18N.pm >@@ -2,7 +2,8 @@ package Koha::I18N; > > # This file is part of Koha. > # >-# Copyright 2012-2014 BibLibre >+# Copyright 2012-2023 BibLibre >+# Copyright 2023 Koha Development Team > # > # Koha is free software; you can redistribute it and/or modify it > # under the terms of the GNU General Public License as published by >@@ -241,7 +242,6 @@ sub db_t { > > my $cache = Koha::Caches->get_instance(); > unless ($cache->is_cache_active) { >- warn "Using Koha::Cache::Memory::Lite"; > $cache = Koha::Cache::Memory::Lite->get_instance(); > } > >diff --git a/Koha/ItemType.pm b/Koha/ItemType.pm >index b0e6931e432..078bd9efb36 100644 >--- a/Koha/ItemType.pm >+++ b/Koha/ItemType.pm >@@ -27,8 +27,6 @@ use Koha::I18N; > > use base qw(Koha::Object Koha::Object::Limit::Library); > >-my $cache = Koha::Caches->get_instance(); >- > =head1 NAME > > Koha::ItemType - Koha Item type Object class >@@ -48,22 +46,7 @@ ItemType 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 $self_from_storage = $self->get_from_storage; >- $flush = 1 if ( $self_from_storage->description ne $self->description ); >- } >- >- $self = $self->SUPER::store; >- >- if ($flush) { >- my $key = "itemtype:description:en"; >- $cache->clear_from_cache($key); >- } >+ Koha::Caches->get_instance('itemtypes')->flush_all; > > return $self; > } >@@ -76,7 +59,9 @@ ItemType specific C<delete> to clear relevant caches on delete. > > sub delete { > my $self = shift @_; >- $cache->clear_from_cache('itemtype:description:en'); >+ >+ Koha::Caches->get_instance('itemtypes')->flush_all; >+ > $self->SUPER::delete(@_); > } > >@@ -106,6 +91,13 @@ sub translation_key { > return $self->itemtype; > } > >+sub get_from_cache { >+ my ( $class, $itemtype ) = @_; >+ my @itemtypes = @{Koha::ItemTypes->get_from_cache}; >+ my ( $cached ) = grep {($_->{itemtype} eq $itemtype) ? $_ : ()} @itemtypes; >+ return $cached; >+} >+ > =head3 image_location > > =cut >diff --git a/Koha/ItemTypes.pm b/Koha/ItemTypes.pm >index 5cc28842b6d..c79d0397493 100644 >--- a/Koha/ItemTypes.pm >+++ b/Koha/ItemTypes.pm >@@ -17,10 +17,7 @@ package Koha::ItemTypes; > > use Modern::Perl; > >- >-use C4::Languages; >- >-use Koha::Database; >+use Koha::Caches; > use Koha::ItemType; > > use base qw(Koha::Objects Koha::Objects::Limit::Library); >@@ -31,6 +28,50 @@ Koha::ItemTypes - Koha ItemType Object set class > > =head1 API > >+=head2 Class Methods >+ >+=head3 get_from_cache >+ >+ my $itemtypes = Koha::ItemTypes->get_from_cache([{ library_limit => $library_id } ]); >+ >+Returns an array of hashrefs representing itemtypes. >+ >+A library_limit parameter can be passed to limit the result to a given library. >+ >+The translation_key and image_location are added to the list of item type's attributes >+ >+=cut >+ >+sub get_from_cache { >+ my ($self, $params) = @_; >+ >+ my $library_limit = >+ ( $params && $params->{library_limit} ) >+ ? $params->{library_limit} || q{} >+ : q{}; >+ >+ my $cache = Koha::Caches->get_instance('itemtypes'); >+ my $cache_key = "ItemTypes:$library_limit"; >+ my $cached = $cache->get_from_cache($cache_key); >+ return $cached if $cached; >+ >+ my $itemtypes = $library_limit >+ ? $self->search_with_library_limits( >+ undef, undef, $params->{library_limit} ) >+ : $self->search; >+ >+ return [ >+ map { >+ { >+ %{ $_->unblessed }, >+ translation_key => $_->translation_key, >+ image_location_opac => $_->image_location('opac'), >+ image_location_staff => $_->image_location('intranet'), >+ } >+ } $itemtypes->as_list >+ ]; >+} >+ > =head2 Internal methods > > =head3 type >diff --git a/Koha/SearchEngine/Elasticsearch/Search.pm b/Koha/SearchEngine/Elasticsearch/Search.pm >index e8e4412b56e..7a72c993fc5 100644 >--- a/Koha/SearchEngine/Elasticsearch/Search.pm >+++ b/Koha/SearchEngine/Elasticsearch/Search.pm >@@ -138,7 +138,7 @@ sub count { > > my ( $error, $results, $facets ) = $search->search_compat( > $query, $simple_query, \@sort_by, \@servers, >- $results_per_page, $offset, undef, $item_types, >+ $results_per_page, $offset, undef, > $query_type, $scan > ) > >@@ -152,7 +152,7 @@ sub search_compat { > my ( > $self, $query, $simple_query, $sort_by, > $servers, $results_per_page, $offset, $branches, >- $item_types, $query_type, $scan >+ $query_type, $scan > ) = @_; > > if ( $scan ) { >@@ -471,7 +471,7 @@ sub _convert_facets { > my @locations = Koha::AuthorisedValues->search( { category => 'LOC' } )->as_list; > my $opac = C4::Context->interface eq 'opac' ; > my %special = ( >- itype => { map { $_->itemtype => $_->description } @itypes }, >+ itype => { map { $_->itemtype => $_->translated_description } @itypes }, > location => { map { $_->authorised_value => ( $opac ? ( $_->lib_opac || $_->lib ) : $_->lib ) } @locations }, > holdingbranch => $library_names, > homebranch => $library_names >diff --git a/Koha/Template/Plugin/ItemTypes.pm b/Koha/Template/Plugin/ItemTypes.pm >index 7cf4a011c67..cefa3aab63d 100644 >--- a/Koha/Template/Plugin/ItemTypes.pm >+++ b/Koha/Template/Plugin/ItemTypes.pm >@@ -32,11 +32,31 @@ sub GetDescription { > return q{} unless defined $itemtype; > my $parent; > $parent = $itemtype->parent if $want_parent; >- return $parent ? $self->t($parent->description) . "->" . $self->t($itemtype->description) : $self->t($itemtype->description); >+ return $parent ? $self->t($parent->translation_key) . "->" . $self->t($itemtype->translation_key) : $self->t($itemtype->translation_key); > } > > sub Get { >- return Koha::ItemTypes->search->unblessed; >+ return Koha::ItemTypes->get_from_cache; >+} >+ >+sub GetSorted { >+ my ( $self ) = @_; >+ >+ my $itemtypes = [ >+ map { >+ { >+ %$_, >+ translated_description => >+ db_t( 'itemtype', $_->{translation_key} ) >+ } >+ } @{Koha::ItemTypes->get_from_cache} >+ ]; >+ >+ return [ >+ sort { >+ $self->t( $a->{translation_key} ) cmp $self->t( $b->{translation_key} ) >+ } @$itemtypes >+ ]; > } > > sub t { >diff --git a/Koha/UI/Form/Builder/Item.pm b/Koha/UI/Form/Builder/Item.pm >index 8ff8363c609..d685e24877d 100644 >--- a/Koha/UI/Form/Builder/Item.pm >+++ b/Koha/UI/Form/Builder/Item.pm >@@ -207,18 +207,11 @@ sub generate_subfield_form { > } > elsif ( $subfield->{authorised_value} eq "itemtypes" ) { > push @authorised_values, ""; >- my $itemtypes; >- if ($branch_limit) { >- $itemtypes = Koha::ItemTypes->search( >- { branchcode => $branch_limit } ); >- } >- else { >- $itemtypes = Koha::ItemTypes->search; >- } >- while ( my $itemtype = $itemtypes->next ) { >- push @authorised_values, $itemtype->itemtype; >- $authorised_lib{ $itemtype->itemtype } = >- db_t('itemtype', $itemtype->translation_key); >+ my $itemtypes = Koha::ItemTypes->get_from_cache({ library_limit => $branch_limit }); >+ for my $itemtype ( @$itemtypes ) { >+ push @authorised_values, $itemtype->{itemtype}; >+ $authorised_lib{ $itemtype->{itemtype} } = >+ db_t('itemtype', $itemtype->{translation_key}); > } > > if (!$value && $biblionumber) { >diff --git a/acqui/orderreceive.pl b/acqui/orderreceive.pl >index 4ee436495bc..232d5c73186 100755 >--- a/acqui/orderreceive.pl >+++ b/acqui/orderreceive.pl >@@ -74,7 +74,6 @@ use Koha::Acquisition::Booksellers; > use Koha::Acquisition::Currencies qw( get_active ); > use Koha::Acquisition::Orders; > use Koha::DateUtils qw( dt_from_string ); >-use Koha::I18N; > use Koha::ItemTypes; > use Koha::Patrons; > >diff --git a/authorities/authorities.pl b/authorities/authorities.pl >index 8bbf57040ce..13e10279f41 100755 >--- a/authorities/authorities.pl >+++ b/authorities/authorities.pl >@@ -32,7 +32,6 @@ use C4::Biblio qw( TransformHtmlToMarc ); > use Koha::Authority::Types; > use Koha::Import::Records; > use Koha::ItemTypes; >-use Koha::I18N; > use vars qw( $tagslib); > use vars qw( $authorised_values_sth); > use vars qw( $is_a_modif ); >diff --git a/catalogue/detail.pl b/catalogue/detail.pl >index 48bd7998796..fe161b4bac2 100755 >--- a/catalogue/detail.pl >+++ b/catalogue/detail.pl >@@ -189,7 +189,8 @@ $template->param( > content_identifier_exists => $content_identifier_exists, > ); > >-my $itemtypes = { map { $_->itemtype => $_ } @{ Koha::ItemTypes->search_with_localization->as_list } }; >+my $itemtypes = { map { $_->itemtype => $_ } @{ Koha::ItemTypes->search->as_list } }; >+ > my $all_items = $biblio->items->search_ordered; > my @items; > my $patron = Koha::Patrons->find( $borrowernumber ); >diff --git a/catalogue/getitem-ajax.pl b/catalogue/getitem-ajax.pl >index bd0e8e0d841..205a842cc52 100755 >--- a/catalogue/getitem-ajax.pl >+++ b/catalogue/getitem-ajax.pl >@@ -27,7 +27,6 @@ use C4::Output qw( output_with_http_headers ); > use Koha::Libraries; > > use Koha::AuthorisedValues; >-use Koha::I18N; > use Koha::Items; > use Koha::ItemTypes; > >diff --git a/catalogue/itemsearch.pl b/catalogue/itemsearch.pl >index f8d44520508..68c2c6e812c 100755 >--- a/catalogue/itemsearch.pl >+++ b/catalogue/itemsearch.pl >@@ -28,7 +28,6 @@ use C4::Koha qw( GetAuthorisedValues ); > > use Koha::AuthorisedValues; > use Koha::Biblios; >-use Koha::I18N; > use Koha::Item::Search::Field qw(GetItemSearchFields); > use Koha::ItemTypes; > use Koha::Libraries; >diff --git a/catalogue/moredetail.pl b/catalogue/moredetail.pl >index 20f58eb318f..4ad6c36f16d 100755 >--- a/catalogue/moredetail.pl >+++ b/catalogue/moredetail.pl >@@ -35,7 +35,6 @@ use Koha::AuthorisedValues; > use Koha::Biblios; > use Koha::Items; > use Koha::Patrons; >-use Koha::I18N; > > my $query=CGI->new; > >@@ -139,10 +138,10 @@ my $ccodes = > my $copynumbers = > { map { $_->{authorised_value} => $_->{lib} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => $fw, kohafield => 'items.copynumber' } ) }; > >-my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search->unblessed } }; >+my $itemtypes = { map { $_->itemtype => $_ } @{ Koha::ItemTypes->search->as_list } }; >+ >+$data->{itemtype} = $itemtypes->{ $data->{itemtype} }; > >-$data->{'itemtypename'} = db_t('itemtype', $itemtypes->{ $data->{'itemtype'} }->{itemtype}) >- if $data->{itemtype} && exists $itemtypes->{ $data->{itemtype} }; > foreach ( keys %{$data} ) { > $template->param( "$_" => defined $data->{$_} ? $data->{$_} : '' ); > } >@@ -155,8 +154,8 @@ foreach my $item (@items){ > > my $item_info = $item->unblessed; > $item_info->{object} = $item; >- $item_info->{itype} = db_t('itemtype', $itemtypes->{ $item_info->{itype} }->{itemtype}) if exists $itemtypes->{ $item_info->{itype} }; >- $item_info->{effective_itemtype} = $itemtypes->{$item->effective_itemtype}; >+ $item_info->{itemtype} = $itemtypes->{$item_info->{itype}}; >+ $item_info->{effective_itemtype} = $itemtypes->{$item->effective_itemtype}; > $item_info->{'ccode'} = $ccodes->{ $item->ccode } if $ccodes && $item->ccode && exists $ccodes->{ $item->ccode }; > if ( defined $item->copynumber ) { > $item_info->{'displaycopy'} = 1; >diff --git a/catalogue/search.pl b/catalogue/search.pl >index 051a9654588..c64d72dadd8 100755 >--- a/catalogue/search.pl >+++ b/catalogue/search.pl >@@ -158,7 +158,6 @@ use Koha::SearchEngine::QueryBuilder; > use Koha::Virtualshelves; > use Koha::SearchFields; > use Koha::SearchFilters; >-use Koha::I18N; > > use URI::Escape; > use JSON qw( decode_json encode_json ); >@@ -543,10 +542,9 @@ my $facets; # this object stores the faceted results that display on the left-ha > my $results_hashref; > > eval { >- my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search->unblessed } }; > ( $error, $results_hashref, $facets ) = $searcher->search_compat( > $query, $simple_query, \@sort_by, \@servers, >- $results_per_page, $offset, undef, $itemtypes, >+ $results_per_page, $offset, undef, > $query_type, $scan > ); > }; >@@ -579,10 +577,9 @@ for (my $i=0;$i<@servers;$i++) { > \@sort_by, $scan, $lang, { weighted_fields => $weight_search, whole_record => $whole_record }); > my $quoted_results_hashref; > eval { >- my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } }; > ( $error, $quoted_results_hashref, $facets ) = $searcher->search_compat( > $query, $simple_query, \@sort_by, ['biblioserver'], >- $results_per_page, $offset, undef, $itemtypes, >+ $results_per_page, $offset, undef, > $query_type, $scan > ); > }; >@@ -811,14 +808,13 @@ sub prepare_adv_search_types { > # the index parameter is different for item-level itemtypes > my $itype_or_itemtype = > ( C4::Context->preference("item-level_itypes") ) ? 'itype' : 'itemtype'; >- my $itemtypes = { >- map { >- $_->{itemtype} => { >- %$_, >- description => db_t( 'itemtype', $_->{itemtype} ), >- } >- } @{ Koha::ItemTypes->search->unblessed } >- }; >+ >+ # FIXME We should retrieve the ItemTypes from the cache >+ my $itemtypes = >+ map { >+ $_->itemtype => >+ { %{ $_->unblessed }, description => $_->translated_description, } >+ } @{ Koha::ItemTypes->search->as_list }; > > my ( $cnt, @result ); > foreach my $advanced_srch_type (@advanced_search_types) { >diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl >index f3ace8b7016..04328bba6be 100755 >--- a/cataloguing/addbiblio.pl >+++ b/cataloguing/addbiblio.pl >@@ -57,7 +57,6 @@ use Koha::Patrons; > use MARC::File::USMARC; > use MARC::File::XML; > use URI::Escape qw( uri_escape_utf8 ); >-use Koha::I18N; > > if ( C4::Context->preference('marcflavour') eq 'UNIMARC' ) { > MARC::File::XML->default_record_format('UNIMARC'); >diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl >index cf571f10aaa..b04ceacc210 100755 >--- a/cataloguing/additem.pl >+++ b/cataloguing/additem.pl >@@ -34,7 +34,6 @@ use C4::Output qw( output_and_exit_if_error output_and_exit output_html_with_htt > use C4::Search qw( enabled_staff_search_views ); > use Koha::Biblios; > use Koha::Item::Templates; >-use Koha::I18N; > use Koha::ItemTypes; > use Koha::Items; > use Koha::Libraries; >diff --git a/circ/transferstoreceive.pl b/circ/transferstoreceive.pl >index fbd21282383..1127c3bb181 100755 >--- a/circ/transferstoreceive.pl >+++ b/circ/transferstoreceive.pl >@@ -28,7 +28,6 @@ use C4::Members; > use Date::Calc qw( Add_Delta_Days Date_to_Days Today ); > > use C4::Reserves; >-use Koha::I18N; > use Koha::Items; > use Koha::ItemTypes; > use Koha::Libraries; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >index e8c92075631..a513851238a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >@@ -405,7 +405,7 @@ > [% IF !noItemTypeImages && itemtype.image_location('intranet') %] > <img src="[% itemtype.image_location('intranet') | html %]" alt="[% ItemTypes.t(itemtype.translation_key) | html %]" title="[% ItemTypes.t(itemtype.translation_key) | html %]" /> > [% END %] >- <span class="itypedesc itypetext">[% ItemTypes.t(item.translation_key) | html %]</span> >+ <span class="itypedesc itypetext">[% ItemTypes.t(itemtype.translation_key) | html %]</span> > </td> > [% END %] > <td class="location">[% UNLESS ( singlebranchmode ) %][% Branches.GetName( item.holdingbranch ) | html %] [% END %]</td> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt >index b220f58002d..131875851bc 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt >@@ -4,6 +4,7 @@ > [% USE Koha %] > [% USE Branches %] > [% USE Price %] >+[% USE ItemTypes %] > [% SET footerjs = 1 %] > [% INCLUDE 'doc-head-open.inc' %] > <title>Item details for [% INCLUDE 'biblio-title-head.inc' %] › Catalog › Koha</title> >@@ -53,7 +54,7 @@ > <ol class="bibliodetails"> > <li><span class="label">Biblionumber:</span> [% biblionumber | html %] </li> > [% UNLESS ( item_level_itypes ) %] >- <li><span class="label">Item type:</span> [% itemtypename | html %] </li> >+ <li><span class="label">Item type:</span> [% ItemTypes.t(itemtype.translation_key) | html %] </li> > [% END %] > [% IF ( rentalcharge ) %] > <li><span class="label">Rental charge:</span>[% rentalcharge | $Price %] </li> >@@ -125,7 +126,7 @@ > <ol class="bibliodetails"> > <li><span class="label">Home library:</span> [% Branches.GetName( ITEM_DAT.homebranch ) | html %] </li> > [% IF ( item_level_itypes ) %] >- <li><span class="label">Item type:</span> [% ITEM_DAT.itype | html %] </li> >+ <li><span class="label">Item type:</span> [% ItemTypes.t(ITEM_DAT.itemtype.translation_key) | html %] </li> > [% END %] > [% IF ( ITEM_DAT.ccode) %] > <li><span class="label">Collection:</span> [% ITEM_DAT.ccode | html %]</li> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt >index b6e43806402..e1fdd02fcdc 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt >@@ -527,10 +527,10 @@ > <td> > [% IF ( !item_level_itypes ) || Koha.Preference('BiblioItemtypeInfo') %] > <div class="result-biblio-itemtype"> >- [% IF !noItemTypeImages && SEARCH_RESULT.imageurl %] >- <img src="[% SEARCH_RESULT.imageurl | html %]" alt="[% SEARCH_RESULT.description | html %]" /> >+ [% IF !noItemTypeImages && SEARCH_RESULT.itemtype.image_location_staff %] >+ <img src="[% SEARCH_RESULT.itemtype.image_location_staff | url %]" alt="[% ItemTypes.t(SEARCH_RESULT.translation_key) | uri %]" /> > [% END %] >- <span class="itypetext">[% SEARCH_RESULT.description | html %]</span> >+ <span class="itypetext">[% ItemTypes.t(SEARCH_RESULT.itemtype.translation_key) | html %]</span> > </div> > [% END %] > >@@ -614,9 +614,9 @@ > [% IF SEARCH_RESULT.${items_loop}.size > 0 %] > <ul class="[% items_loop | html %]_items"> > [% FOREACH items_loo IN SEARCH_RESULT.${items_loop} %] >- [% IF item_level_itypes && !noItemTypeImages && items_loo.imageurl %] >+ [% IF item_level_itypes && !noItemTypeImages && items_loo.itemtype.image_location_staff %] > <li class="result_itype_image"> >- <img src="[% items_loo.imageurl | html %]" title="[% items_loo.description | html %]" alt="[% items_loo.description | html %]" /> >+ <img src="[% items_loo.itemtype.image_location_staff | url %]" title="[% ItemTypes.t(items_loo.itemtype.translation_key) | html %]" alt="[% ItemTypes.t(items_loo.itemtype.translation_key) | html %]" /> > [% ELSE %] > <li> > [% END %] >@@ -658,8 +658,8 @@ > </span> > [% END %] > >- [% IF item_level_itypes && items_loo.description %] >- <span class="item-itype-desc itypetext">[% items_loo.description | html %]</span> >+ [% IF item_level_itypes %] >+ <span class="item-itype-desc itypetext">[% ItemTypes.t(items_loo.itemtype.translation_key) | html %]</span> > [% END %] > </li> > [% END # /FOREACH other_items_loo %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-bib-search.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-bib-search.tt >index de2af58d03a..edd56de74ab 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-bib-search.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-bib-search.tt >@@ -24,9 +24,9 @@ > <label for="itemtypelimit">Limit item type to: </label> > <select name="itemtypelimit" id="itemtypelimit"> > <option value="">All</option> >- [%- FOREACH itemtypeloo IN itemtypeloop %] >- <option value="[% itemtypeloo.code | html %]"> >- [% ItemTypes.t(itemtypeloo.translation_key) | html %] >+ [%- FOREACH itemtype IN ItemTypes.GetSorted() %] >+ <option value="[% itemtype.itemtype | html %]"> >+ [% itemtype.translated_description | html %] > </option> > [%- END %] > </select> >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt >index ab2f28e6158..06ab7c60807 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt >@@ -6,6 +6,7 @@ > [% USE Branches %] > [% USE TablesSettings %] > [% USE AuthorisedValues %] >+[% USE ItemTypes %] > [% SET TagsShowEnabled = ( ( Koha.Preference( 'TagsEnabled' ) == 1 ) && TagsShowOnDetail ) %] > [% SET TagsInputEnabled = ( ( Koha.Preference( 'opacuserlogin' ) == 1 ) && ( Koha.Preference( 'TagsEnabled' ) == 1 ) && TagsInputOnDetail ) %] > [% IF Koha.Preference('AmazonAssocTag') %] >@@ -167,14 +168,13 @@ > > [% IF ( !item_level_itypes || Koha.Preference('BiblioItemtypeInfo') ) %] > <span class="results_summary itemtype"><span class="label">Item type: </span> >- [% IF ( imageurl && !Koha.Preference('OpacNoItemTypeImages') ) %] >- <img src="[% imageurl | html %]" alt="" /> >- [% END %] >- [% IF ( description ) %] >- <span class="itypetext">[% description | html %]</span> >- [% ELSE %] >- <span class="itypetext">[% itemtype | html %]</span> >+ [% IF ( !Koha.Preference('OpacNoItemTypeImages') ) %] >+ [% SET image_url = itemtype.image_location_opac %] >+ [% IF image_url %] >+ <img src="[% image_url | html %]" alt="" /> >+ [% END %] > [% END %] >+ <span class="itypetext">[% ItemTypes.t(itemtype.translation_key) | html %]</span> > </span> > [% END %] > >@@ -1237,12 +1237,14 @@ > > [% IF ( item_level_itypes ) %] > <td class="itype"> >+ [% SET itemtype_description = ItemTypes.t(ITEM_RESULT.itemtype.translation_key) %] > [% UNLESS ( Koha.Preference('OpacNoItemTypeImages') ) %] >- [% IF ( ITEM_RESULT.imageurl ) %] >- <img src="[% ITEM_RESULT.imageurl | html %]" title="[% ITEM_RESULT.description | html %]" alt="[% ITEM_RESULT.description | html %]" /> >+ [% SET image_url = ITEM_RESULT.itemtype.image_location_opac %] >+ [% IF image_url %] >+ <img src="[% image_url | html %]" title="[% itemtype_description | html %]" alt="[% itemtype_description | html %]" /> > [% END %] > [% END %] >- <span class="itypetext">[% ITEM_RESULT.description | html %]</span> >+ <span class="itypetext">[% ITEM_RESULT.itemtype.description | html %]</span> > </td> > [% END %] > [% IF ( OpacLocationBranchToDisplay == 'holding' || OpacLocationBranchToDisplay == 'both' ) %] >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt >index e486da3e249..d0f51ad1c62 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt >@@ -231,8 +231,8 @@ > [% UNLESS ( item_level_itypes ) %] > <li class="itype"> > <span class="label">Item type: </span> >- [% IF ( bibitemloo.imageurl ) %]<img src="[% bibitemloo.imageurl | html %]" alt="" />[% END %] >- <span class="itypetext">[% ItemTypes.t(bibitemloo.translation_key) | html %]</span> >+ [% IF ( bibitemloo.itemtype.image_location_opac ) %]<img src="[% bibitemloo.itemtype.image_location_opac | url %]" alt="" />[% END %] >+ <span class="itypetext">[% ItemTypes.t(bibitemloo.itemtype.translation_key) | html %]</span> > </li> > [% END %] > >@@ -417,11 +417,11 @@ > [% IF ( item_level_itypes ) %] > <td class="itype"> > [% UNLESS ( Koha.Preference('OpacNoItemTypeImages') ) %] >- [% IF ( itemLoo.imageurl ) %] >- <img src="[% itemLoo.imageurl | html %]" alt="" /> >+ [% IF ( itemLoo.itemtype.image_location_opac ) %] >+ <img src="[% itemLoo.itemtype.image_location_opac | html %]" alt="" /> > [% END %] > [% END %] >- <span class="itypetext">[% ItemTypes.t(itemLoo.translation_key) | html %]</span> >+ <span class="itypetext">[% ItemTypes.t(itemLoo.itemtype.translation_key) | html %]</span> > </td> > [% END %] > >diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl >index 7d7b93685c5..a2ae899820c 100755 >--- a/opac/opac-detail.pl >+++ b/opac/opac-detail.pl >@@ -26,7 +26,6 @@ use CGI qw ( -utf8 ); > use C4::Acquisition qw( SearchOrders ); > use C4::Auth qw( get_template_and_user get_session ); > use C4::Koha qw( >- getitemtypeimagelocation > GetNormalizedEAN > GetNormalizedISBN > GetNormalizedOCLCNumber >@@ -71,7 +70,6 @@ use Koha::Biblios; > use Koha::RecordProcessor; > use Koha::AuthorisedValues; > use Koha::CirculationRules; >-use Koha::I18N; > use Koha::Items; > use Koha::ItemTypes; > use Koha::Acquisition::Orders; >@@ -233,7 +231,6 @@ if ($session->param('busc')) { > { > my ($arrParamsBusc, $offset, $results_per_page, $patron) = @_; > >- my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search->unblessed } }; > my @servers; > @servers = @{$arrParamsBusc->{'server'}} if $arrParamsBusc->{'server'}; > @servers = ("biblioserver") unless (@servers); >@@ -247,7 +244,7 @@ if ($session->param('busc')) { > my $searcher = Koha::SearchEngine::Search->new( > { index => $Koha::SearchEngine::BIBLIOS_INDEX } ); > my $json = JSON->new->utf8->allow_nonref(1); >- ($error, $results_hashref, $facets) = $searcher->search_compat($json->decode($arrParamsBusc->{'query'}),$arrParamsBusc->{'simple_query'},\@sort_by,\@servers,$results_per_page,$offset,undef,$itemtypes,$arrParamsBusc->{'query_type'},$arrParamsBusc->{'scan'}); >+ ($error, $results_hashref, $facets) = $searcher->search_compat($json->decode($arrParamsBusc->{'query'}),$arrParamsBusc->{'simple_query'},\@sort_by,\@servers,$results_per_page,$offset,undef,$arrParamsBusc->{'query_type'},$arrParamsBusc->{'scan'}); > }; > my $hits; > my @newresults; >@@ -508,13 +505,8 @@ my $HideMARC = $record_processor->filters->[0]->should_hide_marc( > interface => 'opac', > } ); > >-my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search->unblessed } }; >-# imageurl: >-my $itemtype = $dat->{'itemtype'}; >-if ( $itemtype ) { >- $dat->{'imageurl'} = getitemtypeimagelocation( 'opac', $itemtypes->{$itemtype}->{'imageurl'} ); >- $dat->{'description'} = db_t('itemtype', $itemtypes->{$itemtype}->{itemtype}); >-} >+my $itemtype = Koha::ItemTypes->find($dat->{itemtype}); >+$dat->{itemtype} = $itemtype; > > my $shelflocations = > { map { $_->{authorised_value} => $_->{opac_description} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => $dat->{frameworkcode}, kohafield => 'items.location' } ) }; >@@ -705,11 +697,7 @@ else { > $shelflocations->{ $item->location }; > } > >- my $itemtype = $item->itemtype; >- $item_info->{'imageurl'} = getitemtypeimagelocation( 'opac', >- $itemtypes->{ $itemtype->itemtype }->{'imageurl'} ); >- $item_info->{'description'} = >- db_t('itemtype', $itemtypes->{ $itemtype->itemtype }->{itemtype}); >+ $item_info->{itemtype} = Koha::ItemType->get_from_cache($item->effective_itemtype); > > foreach my $field ( > qw(ccode materials enumchron copynumber itemnotes location_description uri) >@@ -781,7 +769,6 @@ my $marcnotesarray = $biblio->get_marc_notes({ opac => 1, record => $record }); > > if( C4::Context->preference('ArticleRequests') ) { > my $patron = $borrowernumber ? Koha::Patrons->find($borrowernumber) : undef; >- my $itemtype = Koha::ItemTypes->find($biblio->itemtype); > my $artreqpossible = $patron > ? $biblio->can_article_request( $patron ) > : $itemtype >diff --git a/opac/opac-reserve.pl b/opac/opac-reserve.pl >index 981b81c3ded..6e5127d781c 100755 >--- a/opac/opac-reserve.pl >+++ b/opac/opac-reserve.pl >@@ -72,7 +72,8 @@ unless ( $can_place_hold_if_available_at_pickup ) { > } > } > >-my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search->unblessed } }; >+# FIXME Should not we pass a library limit? >+my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->get_from_cache } }; > > # There are two ways of calling this script, with a single biblio num > # or multiple biblio nums. >@@ -413,11 +414,9 @@ foreach my $biblioNum (@biblionumbers) { > $biblioLoopIter{object} = $biblio; > > if (!$itemLevelTypes && $biblioData->{itemtype}) { >- $biblioLoopIter{description} = $itemtypes->{$biblioData->{itemtype}}{description}; >- $biblioLoopIter{imageurl} = getitemtypeimagesrc() . "/". $itemtypes->{$biblioData->{itemtype}}{imageurl}; >+ $biblioLoopIter{itemtype} = $itemtypes->{$biblioData->{itemtype}}; > } > >- > $biblioLoopIter{itemLoop} = []; > my $numCopiesAvailable = 0; > my $numCopiesOPACAvailable = 0; >@@ -433,11 +432,7 @@ foreach my $biblioNum (@biblionumbers) { > $item_info->{holding_branch} = $item->holding_branch; > $item_info->{home_branch} = $item->home_branch; > if ($itemLevelTypes) { >- my $itemtype = $item->itemtype; >- $item_info->{'imageurl'} = getitemtypeimagelocation( 'opac', >- $itemtypes->{ $itemtype->itemtype }->{'imageurl'} ); >- $item_info->{'description'} = >- db_t('itemtype', $itemtypes->{ $itemtype->itemtype }->{description}); >+ $item_info->{itemtype} = $itemtypes->{$item->effective_itemtype}; > } > > # checking for holds >diff --git a/opac/opac-search.pl b/opac/opac-search.pl >index b2c7cc6992a..112f67f3de8 100755 >--- a/opac/opac-search.pl >+++ b/opac/opac-search.pl >@@ -57,7 +57,6 @@ use C4::External::BakerTaylor qw( image_url link_url ); > > use Koha::CirculationRules; > use Koha::Libraries; >-use Koha::I18N; > use Koha::ItemTypes; > use Koha::Ratings; > use Koha::Virtualshelves; >@@ -234,6 +233,7 @@ my $languages_limit_loop = getLanguages($lang, 1); > $template->param(search_languages_loop => $languages_limit_loop,); > > # load the Type stuff >+# FIXME This is not using the ItemTypes cache > my $itemtypes = GetItemTypesCategorized; > foreach my $itemtype ( keys %{$itemtypes} ) { > # Itemtypes search categories don't have (yet) translated descriptions, they are auth values (and could still have no descriptions too BZ 18400) >@@ -577,9 +577,9 @@ if ($tag) { > $pasarParams .= '&count=' . uri_escape_utf8($results_per_page); > $pasarParams .= '&simple_query=' . uri_escape_utf8($simple_query); > $pasarParams .= '&query_type=' . uri_escape_utf8($query_type) if ($query_type); >- my $itemtypes_nocategory = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search->unblessed } }; >+ > eval { >- ($error, $results_hashref, $facets) = $searcher->search_compat($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,undef,$itemtypes_nocategory,$query_type,$scan,1); >+ ($error, $results_hashref, $facets) = $searcher->search_compat($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,undef,$query_type,$scan,1); > }; > } > >@@ -638,9 +638,9 @@ for (my $i=0;$i<@servers;$i++) { > } > ); > my $quoted_results_hashref; >- my $itemtypes_nocategory = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } }; >+ > eval { >- ($error, $quoted_results_hashref, $facets) = $searcher->search_compat($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,undef,$itemtypes_nocategory,$query_type,$scan,1); >+ ($error, $quoted_results_hashref, $facets) = $searcher->search_compat($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,undef,$query_type,$scan,1); > }; > my $quoted_hits = $quoted_results_hashref->{$server}->{"hits"} // 0; > if ( $quoted_hits ){ >diff --git a/reports/issues_stats.pl b/reports/issues_stats.pl >index 02828361850..866c62b3a20 100755 >--- a/reports/issues_stats.pl >+++ b/reports/issues_stats.pl >@@ -75,7 +75,7 @@ our $sep = C4::Context->csv_delimiter(scalar $input->param("sep")); > $template->param(do_it => $do_it, > ); > >-our $itemtypes = Koha::ItemTypes->search->unblessed; >+our $itemtypes = Koha::ItemTypes->get_from_cache; > > our @patron_categories = Koha::Patron::Categories->search_with_library_limits({}, {order_by => ['description']})->as_list; > >@@ -340,7 +340,7 @@ sub calculate { > $cell{rowtitle_display} = > ( $line =~ /ccode/ ) ? $ccodes->{$celvalue} > : ( $line =~ /location/ ) ? $locations->{$celvalue} >- : ( $line =~ /itemtype/ ) ? db_t('itemtype', $itemtypes_map->{$celvalue}->{itemtype}) >+ : ( $line =~ /itemtype/ ) ? db_t('itemtype', $itemtypes_map->{$celvalue}->{translation_key}) > : $celvalue; # default fallback > if ( $line =~ /sort1/ ) { > foreach (@$Bsort1) { >@@ -429,7 +429,7 @@ sub calculate { > $cell{coltitle_display} = > ( $column =~ /ccode/ ) ? $ccodes->{$celvalue} > : ( $column =~ /location/ ) ? $locations->{$celvalue} >- : ( $column =~ /itemtype/ ) ? db_t('itemtype', $itemtypes_map->{$celvalue}->{itemtype}) >+ : ( $column =~ /itemtype/ ) ? db_t('itemtype', $itemtypes_map->{$celvalue}->{translation_key}) > : $celvalue; # default fallback > if ( $column =~ /sort1/ ) { > foreach (@$Bsort1) { >diff --git a/reports/reserves_stats.pl b/reports/reserves_stats.pl >index 5591f132308..490cd1c735c 100755 >--- a/reports/reserves_stats.pl >+++ b/reports/reserves_stats.pl >@@ -28,7 +28,6 @@ use C4::Output qw( output_html_with_http_headers ); > use C4::Reports qw( GetDelimiterChoices ); > use C4::Members; > use Koha::AuthorisedValues; >-use Koha::I18N; > use Koha::ItemTypes; > use Koha::Libraries; > use Koha::Patron::Categories; >diff --git a/serials/subscription-bib-search.pl b/serials/subscription-bib-search.pl >index 52293e8f53d..3920d3897c0 100755 >--- a/serials/subscription-bib-search.pl >+++ b/serials/subscription-bib-search.pl >@@ -192,24 +192,6 @@ else { > } > ); > >- # load the itemtypes >- my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search->unblessed } }; >- my @itemtypesloop; >- # FIXME This is uselessly complex, the iterator should be send to the template >- foreach my $thisitemtype ( >- sort { >- $itemtypes->{$a}->{'description'} >- cmp $itemtypes->{$b}->{'description'} >- } keys %$itemtypes >- ) >- { >- my %row = ( >- code => $thisitemtype, >- description => $itemtypes->{$thisitemtype}->{'description'}, >- ); >- push @itemtypesloop, \%row; >- } >- > # load Collection Codes > my $authvalues = GetAuthorisedValues('CCODE'); > my @ccodesloop; >@@ -223,7 +205,6 @@ else { > } > > $template->param( >- itemtypeloop => \@itemtypesloop, > ccodeloop => \@ccodesloop, > no_query => $op eq "do_search" ? 1 : 0, > ); >diff --git a/svc/checkouts b/svc/checkouts >index 10313c45807..ffc8e765aab 100755 >--- a/svc/checkouts >+++ b/svc/checkouts >@@ -147,7 +147,7 @@ my $item_level_itypes = C4::Context->preference('item-level_itypes'); > my $claims_returned_lost_value = C4::Context->preference('ClaimReturnedLostValue'); > my $confirm_parts_required = C4::Context->preference("CircConfirmItemParts"); > >-my $itemtypes = { map { $_->{itemtype} => db_t('itemtype', $_->{itemtype}) } @{ Koha::ItemTypes->search->unblessed } }; >+my $itemtypes = { map { $_->{itemtype} => db_t('itemtype', $_->{translation_key}) } @{ Koha::ItemTypes->get_from_cache } }; > > my @checkouts_today; > my @checkouts_previous; >diff --git a/t/db_dependent/Koha/Filter/ExpandCodedFields.t b/t/db_dependent/Koha/Filter/ExpandCodedFields.t >index ac33dc9a146..3e5a4d55fa4 100755 >--- a/t/db_dependent/Koha/Filter/ExpandCodedFields.t >+++ b/t/db_dependent/Koha/Filter/ExpandCodedFields.t >@@ -68,7 +68,6 @@ 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); > >diff --git a/t/db_dependent/Koha/Item.t b/t/db_dependent/Koha/Item.t >index d4fbac7f8f3..9f1153e32da 100755 >--- a/t/db_dependent/Koha/Item.t >+++ b/t/db_dependent/Koha/Item.t >@@ -1398,7 +1398,6 @@ 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"); > >@@ -1480,7 +1479,6 @@ 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"); > >@@ -1500,7 +1498,6 @@ 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"); > >@@ -1684,7 +1681,6 @@ 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"); > > $schema->storage->txn_rollback; >diff --git a/tools/batchMod.pl b/tools/batchMod.pl >index d64f8915d5e..6c252ff8494 100755 >--- a/tools/batchMod.pl >+++ b/tools/batchMod.pl >@@ -31,7 +31,6 @@ use List::MoreUtils qw( uniq ); > use Encode qw( encode_utf8 ); > > use Koha::Database; >-use Koha::I18N; > use Koha::Exception; > use Koha::Biblios; > use Koha::Items; >-- >2.25.1
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 24975
:
101703
|
101786
|
102387
|
102388
|
102513
|
102514
|
102688
|
102701
|
132388
|
132508
|
132509
|
132510
|
132511
|
132512
|
132513
|
132514
|
132515
|
132516
|
132517
|
132518
|
132519
|
132520
|
132521
|
132522
|
132523
|
132524
|
132525
|
132526
|
132527
|
132528
|
132529
|
132530
|
132531
|
132532
|
132533
|
132546
|
132562
|
132563
|
132564
|
132565
|
132566
|
132567
|
132568
|
132569
|
132570
|
132571
|
132572
|
132573
|
132574
|
132575
|
149941
|
149942
|
149943
|
149944
|
149945
|
149946
|
149947
|
149948
|
149949
|
149950
|
149951
|
149952
|
149953
|
149954
|
149956
|
149957
| 150015 |
150033
|
150034