From: Mike Rylander Date: Mon, 25 Jan 2016 16:11:24 +0000 (-0500) Subject: LP#1537812: Patron search can time out on useless conditions X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=9c05e6e3874a9a264056c23fd15261ccb8bc2048;p=working%2FEvergreen.git LP#1537812: Patron search can time out on useless conditions In some situations, the patron search code will send an empty or NULL patron group string as part of the search parameters. This is not recognized and causes long (to the point of timing out) search calls. This can be avoided by checking for the presence of a search value. It is not clear where the long-running queries are coming from, though it is likely either the actual patron search interface or from the duplicate check performed during patron registration. Therefore, testing is made particularly difficult. Signed-off-by: Mike Rylander --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/actor.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/actor.pm index e2a4edc3dd..ed605d595a 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/actor.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/actor.pm @@ -664,11 +664,17 @@ sub patron_search { # group 2 = phone, ident # group 3 = barcode - my $usr = join ' AND ', map { "evergreen.lowercase(CAST($_ AS text)) ~ ?" } grep { ''.$$search{$_}{group} eq '0' } keys %$search; - my @usrv = map { "^" . _clean_regex_chars($$search{$_}{value}) } grep { ''.$$search{$_}{group} eq '0' } keys %$search; + my ($usr, @usrv, @usr_key_list, @addr_key_list); + for my $k (keys %search) { + push @usr_key_list, $k if (''.$$search{$k}{group} eq '0' and $$search{$k}{value}); + push @addr_key_list, $k if (''.$$search{$k}{group} eq '1' and $$search{$k}{value}); + } + + my $usr = join ' AND ', map { "evergreen.lowercase(CAST($_ AS text)) ~ ?" } @usr_key_list; + my @usrv = map { "^" . _clean_regex_chars($$search{$_}{value}) } @usr_key_list; - my $addr = join ' AND ', map { "evergreen.lowercase(CAST($_ AS text)) ~ ?" } grep { ''.$$search{$_}{group} eq '1' } keys %$search; - my @addrv = map { "^" . _clean_regex_chars($$search{$_}{value}) } grep { ''.$$search{$_}{group} eq '1' } keys %$search; + my $addr = join ' AND ', map { "evergreen.lowercase(CAST($_ AS text)) ~ ?" } @addr_key_list; + my @addrv = map { "^" . _clean_regex_chars($$search{$_}{value}) } @addr_key_list my $pv = _clean_regex_chars($$search{phone}{value}); my $iv = _clean_regex_chars($$search{ident}{value});