From 763d9ec6e299f6c322bdf1bdfeda39646094ecb4 Mon Sep 17 00:00:00 2001 From: Henri-Damien LAURENT Date: Wed, 4 Mar 2009 11:43:22 +0100 Subject: [PATCH] Searching empty strings broken in Authorities This fixes search on empty strings And if an authtype is provided then it searches on this authtype only Signed-off-by: Henri-Damien LAURENT --- C4/AuthoritiesMarc.pm | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm index 3c1ad9a969..f9bf733f02 100644 --- a/C4/AuthoritiesMarc.pm +++ b/C4/AuthoritiesMarc.pm @@ -101,7 +101,7 @@ returns ref to array result and count of results returned sub SearchAuthorities { my ($tags, $and_or, $excluding, $operator, $value, $offset,$length,$authtypecode,$sortby) = @_; -# warn "CALL : $tags, $and_or, $excluding, $operator, $value, $offset,$length,$authtypecode,$sortby"; + #use Data::Dumper; map {warn "CALL : ".Data::Dumper::Dumper($_);} @_; my $dbh=C4::Context->dbh; if (C4::Context->preference('NoZebra')) { @@ -213,7 +213,6 @@ sub SearchAuthorities { while ($n>1){$query= "\@or ".$query;$n--;} } - my $dosearch; my $and=" \@and " ; my $q2=""; for(my $i = 0 ; $i <= $#{$value} ; $i++) @@ -238,14 +237,13 @@ sub SearchAuthorities { } $attr =$attr."\"".@$value[$i]."\""; $q2 =($q2 ne "" ?$and.$q2.$attr:$attr); - warn $q2; - $dosearch=1; }#if value } ##Add how many queries generated - if ($query=~/\S+/){ + if ($query=~/\S+/ && $q2 ne ""){ $query= $and.$query.$q2; - } else { + } + elsif ($q2 ne "") { $query=$q2; } ## Adding order @@ -257,7 +255,8 @@ sub SearchAuthorities { '@attr 7=2 @attr 1=Heading 0' :'' ); - $query=($query?"\@or $orderstring $query":"\@or \@attr 1=_ALLRECORDS \@attr 2=103 '' $orderstring "); + my $allrecords=" \@attr 1=_ALLRECORDS \@attr 2=103 '' "; + $query=($q2?"\@or $orderstring $query":"\@or $orderstring ".($query?"\@and $allrecords $query":$allrecords) ); $offset=0 unless $offset; my $counter = $offset; -- 2.39.5