From a6a9a169441da317f63c9f1c3b51a0f3ec366ac2 Mon Sep 17 00:00:00 2001 From: Mark Tompsett Date: Tue, 3 Jul 2012 20:22:41 +0800 Subject: [PATCH] Bug 8350 - $search = '0' or 0 will fail to affect SQL statement correctly in C4::Breeding Included moving the substitution into the if statement from Bug 8349 as well. The corrected statement only differs in the case of '' which clearly has no whitespace to substitute. Modified if statements to check defined and length to ensure a cleaner SQL statement. It makes no sense to 'title like %%' on the query. Content-Type: text/plain; charset="utf-8" --- C4/Breeding.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/C4/Breeding.pm b/C4/Breeding.pm index 19bb7e2..ea3e902 100644 --- a/C4/Breeding.pm +++ b/C4/Breeding.pm @@ -179,16 +179,16 @@ sub BreedingSearch { $query .= "z3950random = ?"; @bind=($z3950random); } else { - $search =~ s/(\s+)/\%/g; @bind=(); - if ($search) { + if (defined($search) && length($search)>0) { + $search =~ s/(\s+)/\%/g; $query .= "title like ? OR author like ?"; push(@bind,"%$search%", "%$search%"); } - if ($search && $isbn) { + if ($#bind!=-1 && defined($isbn) && length($isbn)>0) { $query .= " and "; } - if ($isbn) { + if (defined($isbn) && length($isbn)>0) { $query .= "isbn like ?"; push(@bind,"$isbn%"); } -- 1.7.9.5