From 2052299e988d786dde94b640608eac3b84d0bed3 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Fri, 4 Oct 2024 09:11:47 +0000 Subject: [PATCH] Bug 37365: (QA follow-up) Add error checking around AddFile call Content-Type: text/plain; charset=utf-8 Test plan: Add a return; in AddFile to simulate a failing db insert. Verify that an alert pops up. Signed-off-by: Marcel de Rooy --- koha-tmpl/intranet-tmpl/prog/en/modules/members/files.tt | 1 + members/files.pl | 7 +++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/files.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/files.tt index 1abba948ab..f60554a4b6 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/files.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/files.tt @@ -47,6 +47,7 @@
[% IF errors.empty_upload %]The file you are attempting to upload has no contents.[% END %] [% IF errors.no_file %]You did not select a file to upload.[% END %] + [% IF errors.upload_failed %]The upload failed. More information may be in the system logs.[% END %]
[% END %] diff --git a/members/files.pl b/members/files.pl index c09658a2d2..e60a9a7d2a 100755 --- a/members/files.pl +++ b/members/files.pl @@ -87,12 +87,13 @@ else { $file_content .= $_; } - $bf->AddFile( + my $rv = $bf->AddFile( name => $filename, type => $mimetype, content => $file_content, description => scalar $cgi->param('description'), ); + $errors{upload_failed} = 1 unless $rv; } } else { @@ -103,9 +104,7 @@ else { } $template->param( - files => Koha::Patron::Files->new( borrowernumber => $borrowernumber ) - ->GetFilesInfo(), - + files => Koha::Patron::Files->new( borrowernumber => $borrowernumber )->GetFilesInfo(), errors => \%errors, ); output_html_with_http_headers $cgi, $cookie, $template->output; -- 2.39.5