From c8a83c0804b36bf3e814b8483c013bc716d1d806 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Fri, 5 Jun 2015 12:01:28 -0300 Subject: [PATCH] Bug 14344: uninitialized value warning C4/Utils/DataTables/Members.pm The condition for the assignment depends on $searchtype to be defined and equal to 'contains'. So this change doesn't change the semantics. - if $term !~ /^%/ - and $searchtype eq "contain"; + if (defined $searchtype) && $searchtype eq "contain" + && $term !~ /^%/; To test: - Home -> Circulation -> Checkout - Search for a user that does not exist (I searched 'whywouldthisexist') on the intranet interface. - Look at the intranet logs => FAIL: you get "Use of uninitialized value $searchtype in string eq at.,," - Apply the patch - Repeat the search => SUCCESS: No warning - Sign off :-D NOTE: Other pages are more forgiving. Tweaked test plan. Signed-off-by: Mark Tompsett Signed-off-by: Katrin Fischer Signed-off-by: Tomas Cohen Arazi (cherry picked from commit d82aeb352f35ec37fdd62fed7e9a713168a21c28) Signed-off-by: Chris Cormack Signed-off-by: Liz Rea --- C4/Utils/DataTables/Members.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/C4/Utils/DataTables/Members.pm b/C4/Utils/DataTables/Members.pm index 95f6a82c9a..b4cc9e1cf0 100644 --- a/C4/Utils/DataTables/Members.pm +++ b/C4/Utils/DataTables/Members.pm @@ -71,8 +71,8 @@ sub search { $term .= '%' # end with anything if $term !~ /%$/; $term = "%$term" # begin with anythin unless start_with - if $term !~ /^%/ - and $searchtype eq "contain"; + if (defined $searchtype) && $searchtype eq "contain" + && $term !~ /^%/; my @where_strs_or; for my $searchfield ( split /,/, $searchfields->{$searchfieldstype} ) { push @where_strs_or, "borrowers." . $dbh->quote_identifier($searchfield) . " LIKE ?"; -- 2.39.5