Bugzilla – Attachment 50447 Details for
Bug 16282
Usernames should be case sensitive
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 16282 : Making GetMember be case sensitive for userid
Bug-16282--Making-GetMember-be-case-sensitive-for-.patch (text/plain), 4.02 KB, created by
Chris Cormack
on 2016-04-19 22:26:29 UTC
(
hide
)
Description:
Bug 16282 : Making GetMember be case sensitive for userid
Filename:
MIME Type:
Creator:
Chris Cormack
Created:
2016-04-19 22:26:29 UTC
Size:
4.02 KB
patch
obsolete
>From 9a5f644f44e8da6256846cb28c9e2f2f519338bf Mon Sep 17 00:00:00 2001 >From: Chris Cormack <chrisc@catalyst.net.nz> >Date: Wed, 20 Apr 2016 10:08:34 +1200 >Subject: [PATCH] Bug 16282 : Making GetMember be case sensitive for userid > >The main place this changes is SIP > >GetMember with a username is only used in 3 places > >C4/SIP/ILS/Patron.pm: $kp = GetMember(cardnumber=>$patron_id) || GetMember(userid=>$patron_id); >misc/load_testing/benchmark_staff.pl: unless defined C4::Members::GetMember(userid => $user); >tools/import_borrowers.pl: $member = GetMember( 'userid' => $borrower{'userid'} ); > >To Test SIP > >1/ Apply patches, set syspref to No (it should be No already but just in case) >2/ Restart the SIP server >3/ Login to SIP with a userid and password combo >4/ Notice no change, try with different case for userid >5/ Switch on the syspref >6/ Restart the SIP server >7/ Notice the userid/username case sensitive now > >The benchmarking script appears faulty anyway, but if you can get it to run, it should >now care about case sensitive usernames if you have the syspref on. > >To test borrower import >1/ Apply patch, check syspref is No >2/ Import borrowers with the userid being the matchpoint notice case doesn't matter >3/ Switch syspref to Yes >4/ Import borrowers again, now they will only match if the userid(username) matches exactly (Case sensitive) >--- > C4/Members.pm | 58 ++++++++++++++++++++++++++++++++++----------------------- > 1 file changed, 35 insertions(+), 23 deletions(-) > >diff --git a/C4/Members.pm b/C4/Members.pm >index ed82f86..7f30419 100644 >--- a/C4/Members.pm >+++ b/C4/Members.pm >@@ -409,34 +409,46 @@ sub GetMember { > return; > } > my $dbh = C4::Context->dbh; >- my $select = >- q{SELECT borrowers.*, categories.category_type, categories.description >- FROM borrowers >- LEFT JOIN categories on borrowers.categorycode=categories.categorycode WHERE }; >- my $more_p = 0; >- my @values = (); >- for (keys %information ) { >- if ($more_p) { >- $select .= ' AND '; >- } >- else { >- $more_p++; >- } >+ my $sth; >+ if (C4::Context->preference('UsernamesCaseSensitive') && defined $information{userid} ){ >+ my $select = "SELECT * FROM (SELECT borrowers.*, categories.category_type, categories.description >+ FROM borrowers >+ LEFT JOIN categories on borrowers.categorycode=categories.categorycode WHERE >+ userid = ? ) AS firstresult >+ WHERE BINARY userid = ?"; >+ $sth = $dbh->prepare($select); >+ $sth->execute($information{userid},$information{userid}); >+ } >+ else { >+ my $select = >+ q{SELECT borrowers.*, categories.category_type, categories.description >+ FROM borrowers >+ LEFT JOIN categories on borrowers.categorycode=categories.categorycode WHERE }; >+ my $more_p = 0; >+ my @values = (); >+ for (keys %information ) { >+ if ($more_p) { >+ $select .= ' AND '; >+ } >+ else { >+ $more_p++; >+ } > >- if (defined $information{$_}) { >- $select .= "$_ = ?"; >- push @values, $information{$_}; >- } >- else { >- $select .= "$_ IS NULL"; >+ if (defined $information{$_}) { >+ $select .= "$_ = ?"; >+ push @values, $information{$_}; >+ } >+ else { >+ $select .= "$_ IS NULL"; >+ } > } >+ $debug && warn $select, " ",values %information; >+ $sth = $dbh->prepare("$select"); >+ $sth->execute(@values); > } >- $debug && warn $select, " ",values %information; >- my $sth = $dbh->prepare("$select"); >- $sth->execute(@values); > my $data = $sth->fetchall_arrayref({}); > #FIXME interface to this routine now allows generation of a result set >- #so whole array should be returned but bowhere in the current code expects this >+ #so whole array should be returned but nowhere in the current code expects this > if (@{$data} ) { > return $data->[0]; > } >-- >1.7.10.4
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 16282
:
50442
|
50443
| 50447