From 862c2b7c3e08fe4ee6abdb9fd38b2814616e11b8 Mon Sep 17 00:00:00 2001 From: Ulrich Kleiber Date: Mon, 15 Jan 2018 16:26:00 +0100 Subject: [PATCH] Bug 19967: Search patrons with non-Latin languages is brocken. If DefaultPatronSearchFields includes a column with type date, datetime or timestamp, search patrons with non-Latin languages hangis on 'Processing...'. Converting columns with type date, datetime or timestamp to type string eliminates this bug. --- C4/Utils/DataTables/Members.pm | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/C4/Utils/DataTables/Members.pm b/C4/Utils/DataTables/Members.pm index fd00664..4786c3f 100644 --- a/C4/Utils/DataTables/Members.pm +++ b/C4/Utils/DataTables/Members.pm @@ -7,6 +7,11 @@ use C4::Utils::DataTables; use Koha::DateUtils; use C4::Members::Attributes qw(SearchIdMatchingAttribute ); +my $dbh = C4::Context->dbh; + +my $datatime_type_query = "SELECT DISTINCT column_name FROM information_schema.columns WHERE table_name = 'borrowers' AND data_type in ('date', 'datetime', 'timestamp')"; +my @columns_with_datetime_type = @{ $dbh->selectcol_arrayref($datatime_type_query) }; + sub search { my ( $params ) = @_; my $searchmember = $params->{searchmember}; @@ -118,7 +123,12 @@ sub search { my @where_strs_or; for my $searchfield ( split /,/, $searchfields->{$searchfieldstype} ) { - push @where_strs_or, "borrowers." . $dbh->quote_identifier($searchfield) . " LIKE ?"; + if ( grep /^$searchfield$/, @columns_with_datetime_type ) { + push @where_strs_or, "DATE_FORMAT(borrowers." . $dbh->quote_identifier($searchfield) . ", '%Y-%m-%d') LIKE ?"; + } else { + push @where_strs_or, "borrowers." . $dbh->quote_identifier($searchfield) . " LIKE ?"; + } + push @where_args, $term; } -- 2.1.4