Bug 37365: (QA follow-up) Add error checking around AddFile call

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 <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Aleisha Amohia <aleishaamohia@hotmail.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
(cherry picked from commit 35d90969f1)
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit c8cab29919)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
Marcel de Rooy 2024-10-04 09:11:47 +00:00 committed by Fridolin Somers
parent 8768a3f701
commit 78c719ea95
2 changed files with 4 additions and 4 deletions

View File

@ -47,6 +47,7 @@
<div class="dialog alert">
[% 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 %]
</div>
[% END %]

View File

@ -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;