From 140173024d4320c8351baeb955af2e4b99e92bab 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. --- tools/export.pl | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tools/export.pl b/tools/export.pl index ecf4a04..1f1eebe 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.1.4