Bug 17403: Internal Server Error while deleting patron

This patch fixes a Internal Server Error while deleting patrons.

To reproduce:

- Go to a patron's detail page
- Toolbar : More : Delete
- Confirm "Are you sure you want to delete..."

Result: Internal Server Error
Plack error log:
exited nonzero: 1 at /home/marc/koha/members/deletemem.pl
Note: Patron is deleted

Additional tests: Try to delete yourself, to delete a staff member
without having superlibrarian permission etc.

To test:

- Apply patch
- Re-start plack
- Try to reproduce steps above (with other patron)
Expected result:
No Internal Server Error, Redirect to Home > Patrons

Amended to include all occurences of 'exit 1'

Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>

Good catch Marc

Signed-off-by: Katrin Fischer  <katrin.fischer@bsz-bw.de>

Signed-off-by: Brendan Gallagher <brendan@bywatersolutions.com>
(cherry picked from commit b588babdb2)
Signed-off-by: Frédéric Demians <f.demians@tamil.fr>
(cherry picked from commit 0e95348990)
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>
This commit is contained in:
Marc 2016-10-05 15:43:29 +02:00 committed by Julian Maurice
parent 33f3f1c163
commit b2125dcc2f
1 changed files with 5 additions and 4 deletions

View File

@ -52,7 +52,7 @@ my $member = $input->param('member');
#Do not delete yourself...
if ($borrowernumber == $member ) {
print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$member&error=CANT_DELETE_YOURSELF");
exit 1;
exit 0; # Exit without error
}
# Handle deletion from the Norwegian national patron database, if it is enabled
@ -81,12 +81,12 @@ my $userenv = C4::Context->userenv;
if ($bor->{category_type} eq "S") {
unless(C4::Auth::haspermission($userenv->{'id'},{'staffaccess'=>1})) {
print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$member&error=CANT_DELETE_STAFF");
exit 1;
exit 0; # Exit without error
}
} else {
unless(C4::Auth::haspermission($userenv->{'id'},{'borrowers'=>1})) {
print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$member&error=CANT_DELETE");
exit 1;
exit 0; # Exit without error
}
}
@ -95,7 +95,7 @@ if (C4::Context->preference("IndependentBranches")) {
if ( !C4::Context->IsSuperLibrarian() && $bor->{'branchcode'}){
unless ($userenv->{branch} eq $bor->{'branchcode'}){
print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$member&error=CANT_DELETE_OTHERLIBRARY");
exit;
exit 0; # Exit without error
}
}
}
@ -149,6 +149,7 @@ output_html_with_http_headers $input, $cookie, $template->output;
C4::Members::HandleDelBorrower($member);
DelMember($member);
print $input->redirect("/cgi-bin/koha/members/members-home.pl");
exit 0; # Exit without error
}