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 <tomascohen@theke.io>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
(cherry picked from commit df429e4aba)
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Jonathan Druart 2024-10-29 13:52:48 +01:00 committed by Lucas Gass
parent 5178687b67
commit 81ad98eeed
1 changed files with 2 additions and 3 deletions

View File

@ -463,15 +463,14 @@ the I<OpacHiddenItems> 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);
}