From 3bfc5941fa8fa659d18e76552e4e9da07e0c459c 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 --- Koha/Biblio.pm | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm index b8ae982b1de..d4d54eed42b 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.47.0