From 3e11b4a0b47cd55a4d4c0dea9e4302cae694b65a Mon Sep 17 00:00:00 2001 From: Henri-Damien LAURENT Date: Thu, 20 Aug 2009 17:18:24 +0200 Subject: [PATCH] Bug Fixing 3542 : searching for authority in cataloguing There was a problem in the query building and PERL is quite picky with empty data in arrays so setting empty elements to undef Signed-off-by: Chris Cormack --- C4/AuthoritiesMarc.pm | 29 ++++++++++--------- authorities/auth_finder.pl | 2 +- .../prog/en/includes/auth-finder-search.inc | 20 ++++++------- 3 files changed, 26 insertions(+), 25 deletions(-) diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm index 6bfead0186..9f2d9c6a55 100644 --- a/C4/AuthoritiesMarc.pm +++ b/C4/AuthoritiesMarc.pm @@ -101,8 +101,10 @@ returns ref to array result and count of results returned sub SearchAuthorities { my ($tags, $and_or, $excluding, $operator, $value, $offset,$length,$authtypecode,$sortby) = @_; - #use Data::Dumper; map {warn "CALL : ".Data::Dumper::Dumper($_);} @_; +# warn "CALL : $tags, $and_or, $excluding, $operator, $value, $offset,$length,$authtypecode,$sortby"; my $dbh=C4::Context->dbh; + use YAML; + warn "tags : ",Dump($tags),"\noperators:",Dump($operator),"\nvalues:",Dump($value); if (C4::Context->preference('NoZebra')) { # @@ -213,17 +215,17 @@ sub SearchAuthorities { while ($n>1){$query= "\@or ".$query;$n--;} } + my $dosearch; my $and=" \@and " ; - my $q2=""; + my $q2; for(my $i = 0 ; $i <= $#{$value} ; $i++) { if (@$value[$i]){ ##If mainentry search $a tag if (@$tags[$i] eq "mainmainentry") { -# FIXME: 'Heading-Main' index not yet defined in zebra -# $attr =" \@attr 1=Heading-Main "; - $attr =" \@attr 1=Heading "; + $attr =" \@attr 1=Heading-Main "; +# $attr =" \@attr 1=Heading "; }elsif (@$tags[$i] eq "mainentry") { $attr =" \@attr 1=Heading "; @@ -240,16 +242,16 @@ sub SearchAuthorities { $attr .=" \@attr 5=1 \@attr 4=6 ";## Word list, right truncated, anywhere } $attr =$attr."\"".@$value[$i]."\""; - $q2 =($q2 ne "" ?$and.$q2.$attr:$attr); + $q2 =($q2?"$and $q2 $attr":"$attr"); + $dosearch=1; }#if value } ##Add how many queries generated - if ($query=~/\S+/ && $q2 ne ""){ - $query= $and.$query.$q2; - } - elsif ($q2 ne "") { - $query=$q2; - } + if ($query=~/\S+/){ + $query= $and.$query.$q2 + } else { + $query=$q2; + } ## Adding order #$query=' @or @attr 7=2 @attr 1=Heading 0 @or @attr 7=1 @attr 1=Heading 1'.$query if ($sortby eq "HeadingDsc"); my $orderstring= ($sortby eq "HeadingAsc"? @@ -259,8 +261,7 @@ sub SearchAuthorities { '@attr 7=2 @attr 1=Heading 0' :'' ); - my $allrecords=" \@attr 1=_ALLRECORDS \@attr 2=103 '' "; - $query=($q2?"\@or $orderstring $query":"\@or $orderstring ".($query?"\@and $allrecords $query":$allrecords) ); + $query=($query?"\@or $orderstring $query":"\@or \@attr 1=_ALLRECORDS \@attr 2=103 '' $orderstring "); $offset=0 unless $offset; my $counter = $offset; diff --git a/authorities/auth_finder.pl b/authorities/auth_finder.pl index 717771ce9d..18d84b6d19 100755 --- a/authorities/auth_finder.pl +++ b/authorities/auth_finder.pl @@ -59,7 +59,7 @@ if ( $op eq "do_search" ) { my @and_or = $query->param('and_or'); my @excluding = $query->param('excluding'); my @operator = $query->param('operator'); - my @value = ($query->param('value_mainstr'), $query->param('value_main'), $query->param('value_any')); + my @value = ($query->param('value_mainstr')||undef, $query->param('value_main')||undef, $query->param('value_any')||undef); my $orderby = $query->param('orderby'); $resultsperpage = $query->param('resultsperpage'); diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/auth-finder-search.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/auth-finder-search.inc index 17366e98c4..1c7120fbaf 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/auth-finder-search.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/auth-finder-search.inc @@ -33,24 +33,24 @@ " />
  • - + - " />
  • -
  • - - -
  • +
  • + + +
  • Cancel
    -- 2.39.5