Bugzilla – Attachment 189030 Details for
Bug 34069
Add ability to restore a recently deleted borrower from deletedborrowers
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 34069: Add a CannotRestore exception and throw when the userid, borrowernumber, or cardnumber is already in use
Bug-34069-Add-a-CannotRestore-exception-and-throw-.patch (text/plain), 2.50 KB, created by
Lucas Gass (lukeg)
on 2025-11-04 15:36:42 UTC
(
hide
)
Description:
Bug 34069: Add a CannotRestore exception and throw when the userid, borrowernumber, or cardnumber is already in use
Filename:
MIME Type:
Creator:
Lucas Gass (lukeg)
Created:
2025-11-04 15:36:42 UTC
Size:
2.50 KB
patch
obsolete
>From 154cb358b1734ede7cba5889a58d50a5d6ce03e9 Mon Sep 17 00:00:00 2001 >From: Lucas Gass <lucas@bywatersolutions.com> >Date: Mon, 3 Nov 2025 18:33:47 +0000 >Subject: [PATCH] Bug 34069: Add a CannotRestore exception and throw when the > userid, borrowernumber, or cardnumber is already in use > >--- > Koha/Exceptions/Patron.pm | 5 +++++ > Koha/Old/Patron.pm | 29 +++++++++++++++++++++++++++++ > 2 files changed, 34 insertions(+) > >diff --git a/Koha/Exceptions/Patron.pm b/Koha/Exceptions/Patron.pm >index f775e99cd12..7eaa31c9330 100644 >--- a/Koha/Exceptions/Patron.pm >+++ b/Koha/Exceptions/Patron.pm >@@ -41,6 +41,11 @@ use Exception::Class ( > isa => 'Koha::Exceptions::Patron', > description => "Patron not found" > }, >+ 'Koha::Exceptions::Patron::CannotRestore' => { >+ isa => 'Koha::Exceptions::Patron', >+ description => 'The patron cannot be restored due to conflicts', >+ fields => ['type'], >+ }, > ); > > sub full_message { >diff --git a/Koha/Old/Patron.pm b/Koha/Old/Patron.pm >index 61600e7bb1f..62264ed3fac 100644 >--- a/Koha/Old/Patron.pm >+++ b/Koha/Old/Patron.pm >@@ -50,6 +50,35 @@ sub restore_deleted_borrower { > my $schema = Koha::Database->new->schema; > my $restored_patron; > >+ # Check if borrowernumber exists in borrowers. If it does thrown an exception, cannot restore. >+ my $existing_borrower = Koha::Patrons->find( $self->borrowernumber ); >+ if ($existing_borrower) { >+ Koha::Exceptions::Patron::CannotRestore->throw( >+ error => 'Borrowernumber already exists', >+ type => 'borrowernumber', >+ ); >+ } >+ >+ # Check if cardnumber exists in borrowers. If it does thrown an exception, cannot restore. >+ my $existing_cardnumber = Koha::Patrons->find( { cardnumber => $self->cardnumber } ); >+ if ($existing_cardnumber) { >+ Koha::Exceptions::Patron::CannotRestore->throw( >+ error => 'Cardnumber already in use', >+ type => 'cardnumber', >+ ); >+ } >+ >+ # Check if userid exists. If it does thrown an exception, cannot restore. >+ if ( $self->userid ) { >+ my $existing_userid = Koha::Patrons->find( { userid => $self->userid } ); >+ if ($existing_userid) { >+ Koha::Exceptions::Patron::CannotRestore->throw( >+ error => 'Username already in use', >+ type => 'userid', >+ ); >+ } >+ } >+ > $schema->txn_do( > sub { > # Retrive all the data about this patron from deleteborrowers table >-- >2.39.5
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 34069
:
188299
|
188302
|
188988
|
188989
|
188990
|
189027
|
189028
|
189029
|
189030
|
189037
|
189066
|
189067
|
189370
|
189371
|
189372
|
189373
|
189374
|
189375
|
189376
|
189377
|
189642
|
189645
|
189718
|
189773
|
189774
|
189779
|
189780
|
189781
|
189782
|
189783
|
189784
|
189785
|
189786
|
189787
|
189788
|
189789
|
189790
|
189791
|
189792
|
189793
|
189794
|
189795
|
189940
|
189941
|
189942
|
189943
|
189944
|
189945
|
189946
|
189947
|
189948
|
189949
|
189950
|
189951
|
189952
|
189953
|
189954