From 8dad1582c100017f8ad3e331c9a9b9cc9ed4e4d6 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 21 Mar 2017 10:52:42 -0300 Subject: [PATCH] Bug 18312: Fix export unless a file is supplied Bug 18087 breaks export unless a file is supplied. Can't use an undefined value as a HASH reference at /home/vagrant/kohaclone/tools/export.pl line 75. Test plan: Export records using a file of id that is not a valid file (not txt or csv) Export records using a valid file Export records without supplying a file => The export should work or fail as expected. Signed-off-by: Jesse Maseto Signed-off-by: Marcel de Rooy Signed-off-by: Kyle M Hall --- tools/export.pl | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tools/export.pl b/tools/export.pl index ecf4a048c5..1f1eebeb1f 100755 --- a/tools/export.pl +++ b/tools/export.pl @@ -72,11 +72,13 @@ my @branch = $query->multi_param("branch"); my @messages; if ( $op eq 'export' ) { my $filename = $query->param('id_list_file'); - my $mimetype = $query->uploadInfo($filename)->{'Content-Type'}; - my @valid_mimetypes = qw( application/octet-stream text/csv text/plain ); - unless ( grep { /^$mimetype$/ } @valid_mimetypes ) { - push @messages, { type => 'alert', code => 'invalid_mimetype' }; - $op = ''; + if ( $filename ) { + my $mimetype = $query->uploadInfo($filename)->{'Content-Type'}; + my @valid_mimetypes = qw( application/octet-stream text/csv text/plain ); + unless ( grep { /^$mimetype$/ } @valid_mimetypes ) { + push @messages, { type => 'alert', code => 'invalid_mimetype' }; + $op = ''; + } } } -- 2.39.5