Bugzilla – Attachment 183661 Details for
Bug 40275
Add Koha::Patrons->find_by_identifier()
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 40275: Use Koha::Patrons->find_by_identifier in the codebase
Bug-40275-Use-KohaPatrons-findbyidentifier-in-the-.patch (text/plain), 5.11 KB, created by
David Nind
on 2025-06-30 21:42:02 UTC
(
hide
)
Description:
Bug 40275: Use Koha::Patrons->find_by_identifier in the codebase
Filename:
MIME Type:
Creator:
David Nind
Created:
2025-06-30 21:42:02 UTC
Size:
5.11 KB
patch
obsolete
>From 87d86976818aa4805e41543e055fa6f0385ba575 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 30 Jun 2025 15:11:30 -0300 >Subject: [PATCH] Bug 40275: Use Koha::Patrons->find_by_identifier in the > codebase > >Signed-off-by: David Nind <david@davidnind.com> >--- > C4/Auth.pm | 3 +-- > C4/Auth_with_cas.pm | 6 +----- > C4/Circulation.pm | 6 ++---- > C4/SIP/ILS/Patron.pm | 3 +-- > Koha/REST/V1/Auth.pm | 3 +-- > offline_circ/list.pl | 3 +-- > opac/opac-reset-password.pl | 3 +-- > 7 files changed, 8 insertions(+), 19 deletions(-) > >diff --git a/C4/Auth.pm b/C4/Auth.pm >index 2fa9e2bed7..069edd4211 100644 >--- a/C4/Auth.pm >+++ b/C4/Auth.pm >@@ -2146,8 +2146,7 @@ sub checkpw { > } > > if ( defined $userid && !$patron ) { >- $patron = Koha::Patrons->find( { userid => $userid } ); >- $patron = Koha::Patrons->find( { cardnumber => $userid } ) unless $patron; >+ $patron = Koha::Patrons->find_by_identifier($userid); > push @return, $patron if $check_internal_as_fallback; # We pass back the patron if authentication fails > } > >diff --git a/C4/Auth_with_cas.pm b/C4/Auth_with_cas.pm >index 8f4848a87a..f35b7e6871 100644 >--- a/C4/Auth_with_cas.pm >+++ b/C4/Auth_with_cas.pm >@@ -160,11 +160,7 @@ sub checkpw_cas { > > # Does it match one of our users ? > my $dbh = C4::Context->dbh; >- my $patron = Koha::Patrons->find( { userid => $userid } ); >- if ($patron) { >- return ( 1, $patron->cardnumber, $patron->userid, $ticket, $patron ); >- } >- $patron = Koha::Patrons->find( { cardnumber => $userid } ); >+ my $patron = Koha::Patrons->find_by_identifier($userid); > if ($patron) { > return ( 1, $patron->cardnumber, $patron->userid, $ticket, $patron ); > } >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index bf93c32a59..88eff12a7d 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -4494,8 +4494,7 @@ Missing POD for ProcessOfflineIssue. > sub ProcessOfflineIssue { > my $operation = shift; > >- my $patron = Koha::Patrons->find( { cardnumber => $operation->{cardnumber} } ); >- $patron ||= Koha::Patrons->find( { userid => $operation->{cardnumber} } ); >+ my $patron = Koha::Patrons->find_by_identifier( $operation->{cardnumber} ); > > if ($patron) { > my $item = Koha::Items->find( { barcode => $operation->{barcode} } ); >@@ -4536,8 +4535,7 @@ Missing POD for ProcessOfflinePayment. > sub ProcessOfflinePayment { > my $operation = shift; > >- my $patron = Koha::Patrons->find( { cardnumber => $operation->{cardnumber} } ); >- $patron ||= Koha::Patrons->find( { userid => $operation->{cardnumber} } ); >+ my $patron = Koha::Patrons->find_by_identifier( $operation->{cardnumber} ); > > $patron->account->pay( > { >diff --git a/C4/SIP/ILS/Patron.pm b/C4/SIP/ILS/Patron.pm >index e08b845d4f..1caf2888fe 100644 >--- a/C4/SIP/ILS/Patron.pm >+++ b/C4/SIP/ILS/Patron.pm >@@ -59,8 +59,7 @@ sub new { > $patron = Koha::Patrons->find( { userid => $patron_id->{userid} } ); > } > } else { >- $patron = Koha::Patrons->find( { cardnumber => $patron_id } ) >- || Koha::Patrons->find( { userid => $patron_id } ); >+ $patron = Koha::Patrons->find_by_identifier($patron_id); > } > > unless ($patron) { >diff --git a/Koha/REST/V1/Auth.pm b/Koha/REST/V1/Auth.pm >index fd22f1be68..a2b953ba8b 100644 >--- a/Koha/REST/V1/Auth.pm >+++ b/Koha/REST/V1/Auth.pm >@@ -338,8 +338,7 @@ sub _basic_auth { > my $decoded_credentials = decode_base64($credentials); > my ( $identifier, $password ) = split( /:/, $decoded_credentials, 2 ); > >- my $patron = Koha::Patrons->find( { userid => $identifier } ); >- $patron //= Koha::Patrons->find( { cardnumber => $identifier } ); >+ my $patron = Koha::Patrons->find_by_identifier($identifier); > > unless ( checkpw_internal( $identifier, $password ) ) { > Koha::Exceptions::Authorization::Unauthorized->throw( error => 'Invalid password' ); >diff --git a/offline_circ/list.pl b/offline_circ/list.pl >index 6883d98b36..7fabcca671 100755 >--- a/offline_circ/list.pl >+++ b/offline_circ/list.pl >@@ -53,8 +53,7 @@ for (@$operations) { > > my $patron = > $_->{cardnumber} >- ? Koha::Patrons->find( { cardnumber => $_->{cardnumber} } ) >- || Koha::Patrons->find( { userid => $_->{cardnumber} } ) >+ ? Koha::Patrons->find_by_identifier( $_->{cardnumber} ) > : undef; > > if ($patron) { >diff --git a/opac/opac-reset-password.pl b/opac/opac-reset-password.pl >index 834bea16ec..ed30332c08 100755 >--- a/opac/opac-reset-password.pl >+++ b/opac/opac-reset-password.pl >@@ -45,8 +45,7 @@ if ( $op eq 'cud-update' ) { > my $newpassword = $query->param('newpassword'); > my $confirmpassword = $query->param('confirmpassword'); > >- my $patron = Koha::Patrons->find( { userid => $userid } ); >- $patron = Koha::Patrons->find( { cardnumber => $userid } ) unless $patron; >+ my $patron = Koha::Patrons->find_by_identifier($userid); > > if ( $patron && $patron->password_expiration_date ) { > if ( $patron->account_locked ) { >-- >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 40275
:
183647
|
183648
|
183649
|
183659
|
183660
| 183661