From 1396701f96fa66919b8de077e91f0fa89ff1a0ce Mon Sep 17 00:00:00 2001 From: Matthias Le Gac Date: Fri, 16 Feb 2024 10:43:18 -0500 Subject: [PATCH] Bug 34157: Exporting labels as a barcode range can cause 500 error --- C4/Labels/Label.pm | 9 ++++++--- labels/label-create-pdf.pl | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/C4/Labels/Label.pm b/C4/Labels/Label.pm index 1d6ea20e8b..9b7c645cc2 100644 --- a/C4/Labels/Label.pm +++ b/C4/Labels/Label.pm @@ -372,8 +372,11 @@ sub draw_label_text { my $font = $self->{'font'}; my $item = _get_label_item($self->{'item_number'}); my $label_fields = _get_text_fields($self->{'format_string'}); - my $biblio = Koha::Biblios->find($item->{biblionumber}); - my $record = $biblio->metadata->record; + my $biblio = Koha::Biblios->find($item->{'biblionumber'}); + my $record; + if (defined $biblio) { + $record = $biblio->metadata->record; + } # FIXME - returns all items, so you can't get data from an embedded holdings field. # TODO - add a GetMarcBiblio1item(bibnum,itemnum) or a GetMarcItem(itemnum). my $cn_source = ($item->{'cn_source'} ? $item->{'cn_source'} : C4::Context->preference('DefaultClassificationSource')); @@ -391,7 +394,7 @@ sub draw_label_text { $field->{'data'} = C4::Context->preference('item-level_itypes') ? $item->{'itype'} : $item->{'itemtype'}; } else { - $field->{'data'} = _get_barcode_data($field->{'code'},$item,$record); + $field->{'data'} = _get_barcode_data($field->{'code'},$item, $record); } # Find appropriate font it oblique title selected, except main font is oblique if ( ( $field->{'code'} eq 'title' ) and ( $self->{'oblique_title'} == 1 ) ) { diff --git a/labels/label-create-pdf.pl b/labels/label-create-pdf.pl index a5fa56f89b..1f284aaa1c 100755 --- a/labels/label-create-pdf.pl +++ b/labels/label-create-pdf.pl @@ -156,6 +156,7 @@ foreach my $item (@{$items}) { ), ); $pdf->Add($label_a->draw_guide_box) if $layout->get_attr('guidebox'); + print STDERR "label_a: iffffffff"; my $label_a_text = $label_a->create_label(); _print_text($label_a_text); ($row_count, $col_count, $llx, $lly) = _calc_next_label_pos($row_count, $col_count, $llx, $lly); -- 2.34.1