Bug 29002: (follow-up) Make CanBook more resilient

This patch adds a check for biblio existance prior to method resolution
failure in Koha::Template::Plugin::Biblio.

This fixes a failure case in unit tests.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Martin Renvoize 2023-11-03 17:11:51 +00:00 committed by Tomas Cohen Arazi
parent cfc63f77bb
commit 470da48af8
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F

View file

@ -72,6 +72,7 @@ sub CanBook {
my ( $self, $biblionumber ) = @_;
my $biblio = Koha::Biblios->find($biblionumber);
return 0 unless $biblio;
return $biblio->bookable_items->count ? 1 : 0;
}