Bugzilla – Attachment 36808 Details for
Bug 13822
Patron autocomplete search is severly limited
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 13822 - Patron autocomplete search is severly limited
Bug-13822---Patron-autocomplete-search-is-severly-.patch (text/plain), 2.66 KB, created by
Kyle M Hall (khall)
on 2015-03-11 14:58:19 UTC
(
hide
)
Description:
Bug 13822 - Patron autocomplete search is severly limited
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2015-03-11 14:58:19 UTC
Size:
2.66 KB
patch
obsolete
>From e4381ce1effa4cdaa3a5b78df2cbef0488f0e686 Mon Sep 17 00:00:00 2001 >From: ByWater Migration Support <migrations@bywatersolutions.com> >Date: Wed, 11 Mar 2015 07:47:44 -0700 >Subject: [PATCH] Bug 13822 - Patron autocomplete search is severly limited > >The script that returns data for the patron autocomplete does not use C4::Members::Search. Instead it uses bespoke code that does not behave like the traditional search and is very limited in how it can search. > >If, for example, I search for "Kyle Hall" in the standard search, I would get "Kyle Hall" back as a result. For the autocomplete search, I will not. > >This script should use C4::Members::Search to provide better searching and to keep the code base DRY. > >Test Plan: >1) Enable the system preference CircAutocompl >2) Create a user with the first name "Test" and the surname "User" >3) Perform a checkout autocomplete search for "Test User" >4) Note you do not get the user as a result >5) Apply this patch >6) Try different combinations of "Test" and "User" such as > Test User > User Test > U Test > Test U > etc. >7) Note these searches now work >--- > circ/ysearch.pl | 26 ++++---------------------- > 1 files changed, 4 insertions(+), 22 deletions(-) > >diff --git a/circ/ysearch.pl b/circ/ysearch.pl >index 8973902..05c0d79 100755 >--- a/circ/ysearch.pl >+++ b/circ/ysearch.pl >@@ -33,7 +33,7 @@ use C4::Members; > use C4::Auth qw/check_cookie_auth/; > > my $input = new CGI; >-my $query = $input->param('term'); >+my $term = $input->param('term'); > > binmode STDOUT, ":encoding(UTF-8)"; > print $input->header(-type => 'text/plain', -charset => 'UTF-8'); >@@ -43,30 +43,12 @@ if ($auth_status ne "ok") { > exit 0; > } > >-my $dbh = C4::Context->dbh; >-my $sql = q( >- SELECT borrowernumber, surname, firstname, cardnumber, address, city, zipcode, country >- FROM borrowers >- WHERE ( surname LIKE ? >- OR firstname LIKE ? >- OR cardnumber LIKE ? ) >-); >-if ( C4::Context->preference("IndependentBranches") >- && C4::Context->userenv >- && !C4::Context->IsSuperLibrarian() >- && C4::Context->userenv->{'branch'} ) >-{ >- $sql .= " AND borrowers.branchcode =" >- . $dbh->quote( C4::Context->userenv->{'branch'} ); >-} >- >-$sql .= q( ORDER BY surname, firstname LIMIT 10); >-my $sth = $dbh->prepare( $sql ); >-$sth->execute("$query%", "$query%", "$query%"); >+$term =~ s/,//g; #remove any commas from search string >+my ($results) = Search( $term, undef, [ 10 ] ); > > print "["; > my $i = 0; >-while ( my $rec = $sth->fetchrow_hashref ) { >+foreach my $rec ( @$results ) { > if($i > 0){ print ","; } > print "{\"borrowernumber\":\"" . $rec->{borrowernumber} . "\",\"" . > "surname\":\"".$rec->{surname} . "\",\"" . >-- >1.7.2.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 13822
:
36808
|
37009
|
37024
|
37173
|
37177
|
37328
|
37331
|
37522