From e4e54af0e77a01d8ad1ee6ac84f5b255951f1831 Mon Sep 17 00:00:00 2001 From: Janusz Kaczmarek Date: Sat, 11 May 2024 08:41:04 +0000 Subject: [PATCH] Bug 36834: (Bug 29697 follow-up) Koha explodes when trying to open in Labeled MARC view a bibliographic record with an invalid biblionumber After changes made in catalogue/labeledMARCdetail.pl with the bug 29697 when trying to open the Labeled MARC view with biblionumber= (e.g. a deleted biblionumber) Koha explodes with a message << Can't call method "metadata" on an undefined value at /kohadevbox/koha/catalogue/labeledMARCdetail.pl line 59 >> Test plan: ========== 1. Activate the viewLabeledMARC syspref. 2. Try to open a biblio record in Labeled MARC view, giving as a biblionumber (in URL) a non-existing biblionumber, e.g. in ktd, with standard ktd test data: http://your_ktd:8081/cgi-bin/koha/catalogue/labeledMARCdetail.pl?biblionumber=1234567 Koha should explode with the message: Can't call method "metadata" on an undefined value at /kohadevbox/koha/catalogue/labeledMARCdetail.pl line 59 3. Apply the patch; restart_all. 4. Repeat p. 2. You should get a regular page with the info "The record you requested does not exist (1234567)". Signed-off-by: Roman Dolny Signed-off-by: Martin Renvoize Signed-off-by: Katrin Fischer --- catalogue/labeledMARCdetail.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/catalogue/labeledMARCdetail.pl b/catalogue/labeledMARCdetail.pl index 86525162f4..ad8727b0f2 100755 --- a/catalogue/labeledMARCdetail.pl +++ b/catalogue/labeledMARCdetail.pl @@ -56,8 +56,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( ); my $biblio_object = Koha::Biblios->find( $biblionumber ); # FIXME Should replace $biblio -my $record = $biblio_object->metadata->record; -if ( not defined $record ) { +unless ($biblio_object) { # biblionumber invalid -> report and exit $template->param( unknownbiblionumber => 1, biblionumber => $biblionumber @@ -66,6 +65,7 @@ if ( not defined $record ) { exit; } +my $record = $biblio_object->metadata->record; my $tagslib = GetMarcStructure(1,$frameworkcode); my $biblio = GetBiblioData($biblionumber); -- 2.39.5