Bugzilla – Attachment 112922 Details for
Bug 14708
The patron set as the anonymous patron should not be deletable
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14708: (QA follow-up) Use try/catch blocks when calling delete() on a patron
Bug-14708-QA-follow-up-Use-trycatch-blocks-when-ca.patch (text/plain), 2.36 KB, created by
Kyle M Hall (khall)
on 2020-11-03 13:55:22 UTC
(
hide
)
Description:
Bug 14708: (QA follow-up) Use try/catch blocks when calling delete() on a patron
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2020-11-03 13:55:22 UTC
Size:
2.36 KB
patch
obsolete
>From 0017bc67907bdbd48ee3456efe377e9fec9d294d Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Tue, 3 Nov 2020 08:55:04 -0500 >Subject: [PATCH] Bug 14708: (QA follow-up) Use try/catch blocks when calling > delete() on a patron > >--- > Koha/REST/V1/Patrons.pm | 22 +++++++++++++++++----- > members/deletemem.pl | 11 +++++++++-- > 2 files changed, 26 insertions(+), 7 deletions(-) > >diff --git a/Koha/REST/V1/Patrons.pm b/Koha/REST/V1/Patrons.pm >index 04e7a31f64..c3916d6414 100644 >--- a/Koha/REST/V1/Patrons.pm >+++ b/Koha/REST/V1/Patrons.pm >@@ -310,11 +310,23 @@ sub delete { > $patron = Koha::Patrons->find( $c->validation->param('patron_id') ); > > # check if loans, reservations, debarrment, etc. before deletion! >- $patron->delete; >- return $c->render( >- status => 204, >- openapi => q{} >- ); >+ try { >+ $patron->delete; >+ return $c->render( >+ status => 204, >+ openapi => q{} >+ ); >+ } catch { >+ if ( $_->isa('Koha::Exceptions::Patron::FailedDeleteAnonymousPatron') ) { >+ return $c->render( >+ status => 403, >+ openapi => { error => "Anonymous patron cannot be deleted" } >+ ); >+ } >+ else { >+ $c->unhandled_exception($_); >+ } >+ }; > } > catch { > unless ($patron) { >diff --git a/members/deletemem.pl b/members/deletemem.pl >index a01dd39a87..a508498182 100755 >--- a/members/deletemem.pl >+++ b/members/deletemem.pl >@@ -24,6 +24,9 @@ > use Modern::Perl; > > use CGI qw ( -utf8 ); >+ >+use Try::Tiny; >+ > use C4::Context; > use C4::Output; > use C4::Auth; >@@ -127,9 +130,13 @@ if ( $op eq 'delete_confirm' or $countissues > 0 or $debits or $is_guarantor ) { > }); > my $patron = Koha::Patrons->find( $member ); > $patron->move_to_deleted; >- $patron->delete; >+ try { >+ $patron->delete; >+ print $input->redirect("/cgi-bin/koha/members/members-home.pl"); >+ } catch { >+ print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$member&error=CANT_DELETE_ANONYMOUS_PATRON"); >+ } > # TODO Tell the user everything went ok >- print $input->redirect("/cgi-bin/koha/members/members-home.pl"); > exit 0; # Exit without error > } > >-- >2.24.1 (Apple Git-126)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 14708
:
85766
|
85770
|
85783
|
85789
|
103026
|
103027
|
103028
|
103922
|
105024
|
105025
|
105026
|
105027
|
105028
|
105029
|
105184
|
105185
|
105186
|
105187
|
105188
|
105189
|
112830
|
112831
| 112922 |
113121