From 3befc5ead346cf6cfa032bf63bc6d08a05a90279 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Fri, 27 Feb 2026 09:32:23 +0100 Subject: [PATCH] Bug 41444: (QA follow-up) Rearrange comments It would be at least helpful to add a reference to get_transfer here, since we are replacing it here. Used the opportunity to update the older comments Signed-off-by: Marcel de Rooy Signed-off-by: Laura Escamilla (cherry picked from commit eaa354e277c4116f782150b64e2c1e80d77114d2) Signed-off-by: Baptiste Wojtkowski --- C4/Search.pm | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/C4/Search.pm b/C4/Search.pm index 1852dbf0b4..5b03a98e23 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -1907,25 +1907,17 @@ sub searchResults { # is item a waiting recall? my $recallstatus = ''; - unless ($item->{withdrawn} + # Check some statuses before checking transfer info, respect MaxSearchResultsItemsPerRecordStatusCheck + unless ( + $item->{withdrawn} || $item->{itemlost} || $item->{damaged} || $item->{notforloan} || ( C4::Context->preference('MaxSearchResultsItemsPerRecordStatusCheck') && $items_count > C4::Context->preference('MaxSearchResultsItemsPerRecordStatusCheck') ) ) { - # A couple heuristics to limit how many times - # we query the database for item transfer information, sacrificing - # accuracy in some cases for speed; - # - # 1. don't query if item has one of the other statuses - # 2. don't check transit status if the bib has - # more than 20 items - # - # FIXME: to avoid having the query the database like this, and to make - # the in transit status count as unavailable for search limiting, - # should map transit status to record indexed in Zebra. - + # NOTE: We are bypassing an expected Koha::Item->get_transfer call here for speed. + # TODO: Could we index the transfer status ? my $transfer = Koha::Item::Transfers->search( { itemnumber => $item->{itemnumber}, datearrived => undef, datecancelled => undef }, { order_by => [ { '-desc' => 'datesent' }, { '-asc' => 'daterequested' } ] }