From 0118a245b3d4911914ef7f3b92b7d9ea89329993 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 4 Nov 2016 14:43:21 +0000 Subject: [PATCH] Bug 17554: Koha::Patrons - Remove GetBorrowersWithEmail C4::Members::GetBorrowersWithEmail can be easily replaced with Koha::Patrons->search({ email => $email }); Test plan: Confirm that you are still able to use Persona for login http://translate.koha-community.org/manual/master/en/html-desktop/#mozillapersona For QA: Note that this is also use for the PKI authentication But as the code is the same I don't think it's needed to test both. --- C4/Auth.pm | 16 +++++++--------- C4/Members.pm | 28 ---------------------------- 2 files changed, 7 insertions(+), 37 deletions(-) diff --git a/C4/Auth.pm b/C4/Auth.pm index 6b7dc66..51a18e5 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -966,12 +966,11 @@ sub checkauth { # doesn't have a userid. So if there is none, we pass along the # borrower number, and the bits of code that need to know the user # ID will have to be smart enough to handle that. - require C4::Members; - my @users_info = C4::Members::GetBorrowersWithEmail($value); - if (@users_info) { - + my $patrons = Koha::Patrons->search({ email => $value }); + if ($patrons->count) { + my $patron = $patrons->next; # First the userid, then the borrowernum - $value = $users_info[0][1] || $users_info[0][0]; + $value = $patron->userid || $patron->borrowernumber; } else { undef $value; @@ -997,12 +996,11 @@ sub checkauth { # doesn't have a userid. So if there is none, we pass along the # borrower number, and the bits of code that need to know the user # ID will have to be smart enough to handle that. - require C4::Members; - my @users_info = C4::Members::GetBorrowersWithEmail($value); - if (@users_info) { + my $patrons = Koha::Patrons->search({ email => $value }); + if ($patrons->count) { # First the userid, then the borrowernum - $value = $users_info[0][1] || $users_info[0][0]; + $value = $patron->userid || $patron->borrowernumber; } else { undef $value; } diff --git a/C4/Members.pm b/C4/Members.pm index 8953d85..5d4fa6c 100644 --- a/C4/Members.pm +++ b/C4/Members.pm @@ -85,7 +85,6 @@ BEGIN { &GetUpcomingMembershipExpires &IssueSlip - GetBorrowersWithEmail GetOverduesForPatron ); @@ -1608,33 +1607,6 @@ sub IssueSlip { ); } -=head2 GetBorrowersWithEmail - - ([$borrnum,$userid], ...) = GetBorrowersWithEmail('me@example.com'); - -This gets a list of users and their basic details from their email address. -As it's possible for multiple user to have the same email address, it provides -you with all of them. If there is no userid for the user, there will be an -C there. An empty list will be returned if there are no matches. - -=cut - -sub GetBorrowersWithEmail { - my $email = shift; - - my $dbh = C4::Context->dbh; - - my $query = "SELECT borrowernumber, userid FROM borrowers WHERE email=?"; - my $sth=$dbh->prepare($query); - $sth->execute($email); - my @result = (); - while (my $ref = $sth->fetch) { - push @result, $ref; - } - die "Failure searching for borrowers by email address: $sth->errstr" if $sth->err; - return @result; -} - =head2 AddMember_Opac =cut -- 2.1.4