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=<invalid_number> (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 <roman.dolny@jezuici.pl>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
(cherry picked from commit e4e54af0e7)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
(cherry picked from commit 944f3ffc8f)
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Janusz Kaczmarek 2024-05-11 08:41:04 +00:00 committed by Lucas Gass
parent 6d226640b1
commit e16fea9ec5
1 changed files with 2 additions and 2 deletions

View File

@ -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);