From df429e4aba6b94bee7bc07691334475a9817c420 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 --- Koha/Biblio.pm | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm index b8ae982b1d..d4d54eed42 100644 --- a/Koha/Biblio.pm +++ b/Koha/Biblio.pm @@ -470,15 +470,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); } -- 2.39.5