Bug 35266: Fix biblio check in opac-MARCdetail

We should check before retrieving metadata.

Test plan;
Try /cgi-bin/koha/opac-MARCdetail?biblionumber=X
Replace X by a not-existing biblionumber.
Verify that you get a 404 error page.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: David Nind <david@davidnind.com>

JD amended patch: Use ternary op

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Marcel de Rooy 2023-11-06 13:11:49 +00:00 committed by Tomas Cohen Arazi
parent 6a9b6a2e00
commit 54bdcaef66
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F

View file

@ -92,8 +92,8 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
my $patron = Koha::Patrons->find($loggedinuser);
my $biblio = Koha::Biblios->find($biblionumber);
my $record = $biblio->metadata->record;
my $record = $biblio ? $biblio->metadata->record : undef;
if ( ! $record ) {
print $query->redirect("/cgi-bin/koha/errors/404.pl");
exit;