Bug 21475: Fix crash on missing default itemtype

Test plan:
Enable ArticleRequests.
Find book without itemtype (942c). Maybe you need this:
  update biblioitems set itemtype=NULL where biblionumber=[...]
Goto opac detail for that book. No crash anymore?

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
This commit is contained in:
Marcel de Rooy 2018-10-15 14:01:14 +02:00 committed by Nick Clemens
parent 17e5691daa
commit 8d0e08fdf5

View file

@ -758,9 +758,12 @@ my $subtitle = GetRecordValue('subtitle', $record, GetFrameworkCode($bib
if( C4::Context->preference('ArticleRequests') ) {
my $patron = $borrowernumber ? Koha::Patrons->find($borrowernumber) : undef;
my $itemtype = Koha::ItemTypes->find($biblio->itemtype);
my $artreqpossible = $patron
? $biblio->can_article_request( $patron )
: Koha::ItemTypes->find($biblio->itemtype)->may_article_request;
: $itemtype
? $itemtype->may_article_request
: q{};
$template->param( artreqpossible => $artreqpossible );
}