From 81ad98eeed04c7b62b1ba6ee0e72e87fb686e363 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 29 Oct 2024 13:52:48 +0100 Subject: [PATCH] Bug 38286: Do not fetch the items if OpacHiddenItemsHidesRecord is set Koha::Biblio:hidden_in_opac does not need to fetch the items if OpacHiddenItemsHidesRecord is set Test plan: prove t/db_dependent/Koha/Biblio.t t/db_dependent/Koha/Item.t t/db_dependent/api/v1/biblios.t Should return green Confirm the assumption above is correct. Signed-off-by: Tomas Cohen Arazi Signed-off-by: Katrin Fischer (cherry picked from commit df429e4aba6b94bee7bc07691334475a9817c420) Signed-off-by: Lucas Gass --- Koha/Biblio.pm | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm index 1fdcad53d1..4c7867b6ee 100644 --- a/Koha/Biblio.pm +++ b/Koha/Biblio.pm @@ -463,15 +463,14 @@ the I system preference. sub hidden_in_opac { my ( $self, $params ) = @_; + return 0 unless C4::Context->preference('OpacHiddenItemsHidesRecord'); + my $rules = $params->{rules} // {}; my @items = $self->items->as_list; return 0 unless @items; # Do not hide if there is no item - # Ok, there are items, don't even try the rules unless OpacHiddenItemsHidesRecord - return 0 unless C4::Context->preference('OpacHiddenItemsHidesRecord'); - return !(any { !$_->hidden_in_opac({ rules => $rules }) } @items); }