Bug 4491: FIX buildQuery if called with an empty limit
authorJonathan Druart <jonathan.druart@biblibre.com>
Wed, 22 Aug 2012 12:12:09 +0000 (14:12 +0200)
committerPaul Poulain <paul.poulain@biblibre.com>
Mon, 17 Sep 2012 16:19:49 +0000 (18:19 +0200)
if @limit=('') buildQuery failed

Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
All searches that I tried (keyword, indexed, CCL, with limits, without,
etc.) worked fine. There are warnings about uninitialized variables in
the OPAC, but they exist on master as well and therefore should not
block these patches.

Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
C4/Search.pm

index 91bfbb0..04ebe3b 100644 (file)
@@ -1101,7 +1101,8 @@ sub buildQuery {
         my $q=$';
         # This is needed otherwise ccl= and &limit won't work together, and
         # this happens when selecting a subject on the opac-detail page
-        if (@limits) {
+        @limits = grep {!/^$/} @limits;
+        if ( @limits ) {
             $q .= ' and '.join(' and ', @limits);
         }
         return ( undef, $q, $q, "q=ccl=$q", $q, '', '', '', '', 'ccl' );
@@ -1318,6 +1319,7 @@ sub buildQuery {
     my %group_OR_limits;
     my $availability_limit;
     foreach my $this_limit (@limits) {
+        next unless $this_limit;
         if ( $this_limit =~ /available/ ) {
 #
 ## 'available' is defined as (items.onloan is NULL) and (items.itemlost = 0)