Bug 16747 - Patron card creator broken with version 16.05
authorMarc Véron <veron@veron.ch>
Thu, 16 Jun 2016 07:27:55 +0000 (09:27 +0200)
committerBrendan Gallagher <brendan@bywatersolutions.com>
Tue, 21 Jun 2016 20:48:50 +0000 (20:48 +0000)
To reproduce:
- Prepare a patron car layout with Image 1 using Patron Image
- Create a patron card for a patron without patron image
Result: OK, PDF can be opened wit PDF viewer
- Try to create a patron card with a patron who has a patron image
Result: The PDF file is corrupt (contains text only with error message)
        intranet error log contains: create-pdf.pl: Illegal division
        by zero at /usr/share/kohaclone/patroncards/create-pdf.pl line 200
To test:
- Apply patch
- Create a patron card with a patron who has a patron image
Result: PDF is OK and contains the image

Bonus test: Do the same with a card layout with an additional image
(Image 2: Image source: Other image)

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Test and bonus test pass: PDF generated without errors.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Brendan Gallagher <brendan@bywatersolutions.com>
patroncards/create-pdf.pl

index 6d352b4..1811f0f 100755 (executable)
@@ -158,7 +158,12 @@ foreach my $item (@{$items}) {
                 }
                 elsif ($images->{$_}->{'data_source'}->[0]->{'image_source'} eq 'patronimages') {
                     my $patron_image = Koha::Patron::Images->find($borrower_number);
-                    warn sprintf('No image exists for borrower number %s.', $borrower_number) unless $patron_image;
+                    if ($patron_image) {
+                        $image_data->{'imagefile'} = $patron_image->imagefile;
+                    }
+                    else {
+                        warn sprintf('No image exists for borrower number %s.', $borrower_number);
+                    }
                     next PROCESS_IMAGES unless $patron_image;
                 }
                 elsif ($images->{$_}->{'data_source'}->[0]->{'image_source'} eq 'creator_images') {