Bugzilla – Attachment 37024 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]
[Signed-off] Bug 13822 - Patron autocomplete search is severly limited
Signed-off-Bug-13822---Patron-autocomplete-search-.patch (text/plain), 2.86 KB, created by
Marc Véron
on 2015-03-20 09:49:30 UTC
(
hide
)
Description:
[Signed-off] Bug 13822 - Patron autocomplete search is severly limited
Filename:
MIME Type:
Creator:
Marc Véron
Created:
2015-03-20 09:49:30 UTC
Size:
2.86 KB
patch
obsolete
>From 69e2b4009d4eb217c5dd13f8b5c625671cf5c291 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Wed, 11 Mar 2015 07:47:44 -0700 >Subject: [PATCH] [Signed-off] Bug 13822 - Patron autocomplete search is > severly limited >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >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 > >Folllowed test plan, works as expected >Signed-off-by: Marc Véron <veron@veron.ch> >--- > circ/ysearch.pl | 27 +++++---------------------- > 1 file changed, 5 insertions(+), 22 deletions(-) > >diff --git a/circ/ysearch.pl b/circ/ysearch.pl >index 4ac19f5..7c563cf 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,13 @@ 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 $order_by = 'surname, firstname'; >+my ($results) = Search( $term, $order_by, [ 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.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 13822
:
36808
|
37009
|
37024
|
37173
|
37177
|
37328
|
37331
|
37522