From 19fea800e558cbefbc6fb48736a1f0c5ae505389 Mon Sep 17 00:00:00 2001 From: Fridolin Somers Date: Mon, 14 Feb 2022 11:37:53 -1000 Subject: [PATCH] Bug 30089: Fix placing holds on OPAC after Bug 29844 When trying to place a hold in the OPAC, either multi hold or a single hold, the page explodes with: The method Koha::AuthorisedValues->authorised_value is not covered by tests! We could fix by adding ->as_list. This patch fixes by using Koha::AuthorisedValues->get_description_by_koha_field on each item instead of Koha::AuthorisedValues->search_by_koha_field list. Performance should be OK because this method as cache. This is used a lot in staff interface. Test plan : 1) In staff interface find a record with several items available For example in KTD biblionumer=126 2) Edit on item and change 'not for loan' to a non-zero value For example in KTD $7 = Staff Collection 3) Go to OPAC on this record 4) Place hold 5) Click on 'A specific item' => Check you see not for loan authorised value description For example in KTD '(Staff Collection)' --- opac/opac-reserve.pl | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/opac/opac-reserve.pl b/opac/opac-reserve.pl index e8810650f7..d01da5fad0 100755 --- a/opac/opac-reserve.pl +++ b/opac/opac-reserve.pl @@ -460,9 +460,6 @@ foreach my $biblioNum (@biblionumbers) { } } - my @notforloan_avs = Koha::AuthorisedValues->search_by_koha_field({ kohafield => 'items.notforloan', frameworkcode => $frameworkcode }); - my $notforloan_label_of = { map { $_->authorised_value => $_->opac_description } @notforloan_avs }; - my $visible_items = { map { $_->itemnumber => $_ } $biblio->items->filter_by_visible_in_opac( { patron => $patron } )->as_list }; # Only keep the items that are visible in the opac (i.e. those in %visible_items) @@ -525,10 +522,16 @@ foreach my $biblioNum (@biblionumbers) { $itemLoopIter->{itemnotforloan} = $itemInfo->{itemnotforloan}; # Management of the notforloan document - if ( $itemLoopIter->{notforloan} || $itemLoopIter->{itemnotforloan}) { + if ( $itemLoopIter->{notforloan} || $itemLoopIter->{itemnotforloan} ) { $itemLoopIter->{backgroundcolor} = 'other'; - $itemLoopIter->{notforloanvalue} = - $notforloan_label_of->{ $itemLoopIter->{notforloan} }; + my $notforloan_av = Koha::AuthorisedValues->get_description_by_koha_field( + { + frameworkcode => $frameworkcode, + kohafield => 'items.notforloan', + authorised_value => $itemLoopIter->{notforloan} + } + ); + $itemLoopIter->{notforloanvalue} = $notforloan_av->{opac_description} // ''; } # Management of lost or long overdue items -- 2.35.1