View | Details | Raw Unified | Return to bug 5415
Collapse All | Expand All

(-)a/C4/AuthoritiesMarc.pm (-2 / +7 lines)
Lines 362-368 sub CountUsage { Link Here
362
        my $query;
362
        my $query;
363
        $query= "an=".$authid;
363
        $query= "an=".$authid;
364
  		my ($err,$res,$result) = C4::Search::SimpleSearch($query,0,10);
364
  		my ($err,$res,$result) = C4::Search::SimpleSearch($query,0,10);
365
        return ($result);
365
        if ($err) {
366
            warn "Error: $err from search $query";
367
            $result = 0;
368
        }
369
370
        return $result;
366
    }
371
    }
367
}
372
}
368
373
Lines 903-909 sub FindDuplicateAuthority { Link Here
903
    }
908
    }
904
    my ($error, $results, $total_hits) = C4::Search::SimpleSearch( $query, 0, 1, [ "authorityserver" ] );
909
    my ($error, $results, $total_hits) = C4::Search::SimpleSearch( $query, 0, 1, [ "authorityserver" ] );
905
    # there is at least 1 result => return the 1st one
910
    # there is at least 1 result => return the 1st one
906
    if (@$results>0) {
911
    if (!defined $error && @{$results} ) {
907
      my $marcrecord = MARC::File::USMARC::decode($results->[0]);
912
      my $marcrecord = MARC::File::USMARC::decode($results->[0]);
908
      return $marcrecord->field('001')->data,BuildSummary($marcrecord,$marcrecord->field('001')->data,$authtypecode);
913
      return $marcrecord->field('001')->data,BuildSummary($marcrecord,$marcrecord->field('001')->data,$authtypecode);
909
    }
914
    }
(-)a/C4/Heading.pm (+7 lines)
Lines 24-29 use MARC::Field; Link Here
24
use C4::Context;
24
use C4::Context;
25
use C4::Heading::MARC21;
25
use C4::Heading::MARC21;
26
use C4::Search;
26
use C4::Search;
27
use Carp;
27
28
28
our $VERSION = 3.00;
29
our $VERSION = 3.00;
29
30
Lines 109-114 sub authorities { Link Here
109
    my $query = qq(Match-heading,ext="$self->{'search_form'}");
110
    my $query = qq(Match-heading,ext="$self->{'search_form'}");
110
    $query .= $self->_query_limiters();
111
    $query .= $self->_query_limiters();
111
    my ($error, $results, $total_hits) = SimpleSearch( $query, undef, undef, [ "authorityserver" ] );
112
    my ($error, $results, $total_hits) = SimpleSearch( $query, undef, undef, [ "authorityserver" ] );
113
    if (defined $error) {
114
        carp "Error:$error from search $query";
115
    }
112
    return $results;
116
    return $results;
113
}
117
}
114
118
Lines 126-131 sub preferred_authorities { Link Here
126
    my $query = "Match-heading-see-from,ext='$self->{'search_form'}'";
130
    my $query = "Match-heading-see-from,ext='$self->{'search_form'}'";
127
    $query .= $self->_query_limiters();
131
    $query .= $self->_query_limiters();
128
    my ($error, $results, $total_hits) = SimpleSearch( $query, undef, undef, [ "authorityserver" ] );
132
    my ($error, $results, $total_hits) = SimpleSearch( $query, undef, undef, [ "authorityserver" ] );
133
    if (defined $error) {
134
        carp "Error:$error from search $query";
135
    }
129
    return $results;
136
    return $results;
130
}
137
}
131
138
(-)a/C4/Matcher.pm (-3 / +6 lines)
Lines 606-614 sub get_matches { Link Here
606
        # FIXME only searching biblio index at the moment
606
        # FIXME only searching biblio index at the moment
607
        my ($error, $searchresults, $total_hits) = SimpleSearch($query, 0, $max_matches);
607
        my ($error, $searchresults, $total_hits) = SimpleSearch($query, 0, $max_matches);
608
608
609
        warn "search failed ($query) $error" if $error;
609
        if (defined $error ) {
610
        foreach my $matched (@$searchresults) {
610
            warn "search failed ($query) $error";
611
            $matches{$matched} += $matchpoint->{'score'};
611
        } else {
612
            foreach my $matched (@{$searchresults}) {
613
                $matches{$matched} += $matchpoint->{'score'};
614
            }
612
        }
615
        }
613
    }
616
    }
614
617
(-)a/acqui/neworderbiblio.pl (-7 / +6 lines)
Lines 112-127 if (defined $error) { Link Here
112
112
113
my @results;
113
my @results;
114
114
115
if ($marcresults) {
115
foreach my $result ( @{$marcresults} ) {
116
    foreach my $result ( @{$marcresults} ) {
116
    my $marcrecord = MARC::File::USMARC::decode( $result );
117
        my $marcrecord = MARC::File::USMARC::decode( $result );
117
    my $biblio = TransformMarcToKoha( C4::Context->dbh, $marcrecord, '' );
118
        my $biblio = TransformMarcToKoha( C4::Context->dbh, $marcrecord, '' );
119
118
120
        $biblio->{booksellerid} = $booksellerid;
119
    $biblio->{booksellerid} = $booksellerid;
121
        push @results, $biblio;
120
    push @results, $biblio;
122
121
123
    }
124
}
122
}
123
125
$template->param(
124
$template->param(
126
    basketno             => $basketno,
125
    basketno             => $basketno,
127
    booksellerid     => $bookseller->{'id'},
126
    booksellerid     => $bookseller->{'id'},
(-)a/authorities/authorities-list.pl (+3 lines)
Lines 25-30 foreach my $authority (@$dataauthorities){ Link Here
25
  $query= "an=".$authority->{'authid'};
25
  $query= "an=".$authority->{'authid'};
26
  # search for biblios mapped
26
  # search for biblios mapped
27
  my ($err,$res,$used) = C4::Search::SimpleSearch($query,0,10);
27
  my ($err,$res,$used) = C4::Search::SimpleSearch($query,0,10);
28
  if (defined $err) {
29
      $used = 0;
30
  }
28
  if ($marcauthority && $marcauthority->field($authtypes{$authority->{'authtypecode'}}->{'tag'})){
31
  if ($marcauthority && $marcauthority->field($authtypes{$authority->{'authtypecode'}}->{'tag'})){
29
    print qq("),$marcauthority->field($authtypes{$authority->{'authtypecode'}}->{"tag"})->as_string(),qq(";),qq($authority->{'authid'};"),$authtypes{$authority->{'authtypecode'}}->{'lib'},qq(";$used\n);
32
    print qq("),$marcauthority->field($authtypes{$authority->{'authtypecode'}}->{"tag"})->as_string(),qq(";),qq($authority->{'authid'};"),$authtypes{$authority->{'authtypecode'}}->{'lib'},qq(";$used\n);
30
  }
33
  }
(-)a/cataloguing/addbiblio.pl (-3 / +3 lines)
Lines 768-783 AND (authtypecode IS NOT NULL AND authtypecode<>\"\")|); Link Here
768
        warn "BIBLIOADDSAUTHORITIES: $error";
768
        warn "BIBLIOADDSAUTHORITIES: $error";
769
	    return (0,0) ;
769
	    return (0,0) ;
770
	  }
770
	  }
771
      if ($results && scalar(@$results)==1) {
771
      if ( @{$results} == 1) {
772
        my $marcrecord = MARC::File::USMARC::decode($results->[0]);
772
        my $marcrecord = MARC::File::USMARC::decode($results->[0]);
773
        $field->add_subfields('9'=>$marcrecord->field('001')->data);
773
        $field->add_subfields('9'=>$marcrecord->field('001')->data);
774
        $countlinked++;
774
        $countlinked++;
775
      } elsif (scalar(@$results)>1) {
775
      } elsif (@{$results} > 1) {
776
   #More than One result 
776
   #More than One result 
777
   #This can comes out of a lack of a subfield.
777
   #This can comes out of a lack of a subfield.
778
#         my $marcrecord = MARC::File::USMARC::decode($results->[0]);
778
#         my $marcrecord = MARC::File::USMARC::decode($results->[0]);
779
#         $record->field($data->{tagfield})->add_subfields('9'=>$marcrecord->field('001')->data);
779
#         $record->field($data->{tagfield})->add_subfields('9'=>$marcrecord->field('001')->data);
780
  $countlinked++;
780
        $countlinked++;
781
      } else {
781
      } else {
782
  #There are no results, build authority record, add it to Authorities, get authid and add it to 9
782
  #There are no results, build authority record, add it to Authorities, get authid and add it to 9
783
  ###NOTICE : This is only valid if a subfield is linked to one and only one authtypecode     
783
  ###NOTICE : This is only valid if a subfield is linked to one and only one authtypecode     
(-)a/cataloguing/addbooks.pl (-2 / +2 lines)
Lines 85-92 if ($query) { Link Here
85
85
86
    # format output
86
    # format output
87
    # SimpleSearch() give the results per page we want, so 0 offet here
87
    # SimpleSearch() give the results per page we want, so 0 offet here
88
    my $total = scalar @$marcresults;
88
    my $total = @{$marcresults};
89
    my @newresults = searchResults( 'intranet', $query, $total, $results_per_page, 0, 0, @$marcresults );
89
    my @newresults = searchResults( 'intranet', $query, $total, $results_per_page, 0, 0, @{$marcresults} );
90
    $template->param(
90
    $template->param(
91
        total          => $total_hits,
91
        total          => $total_hits,
92
        query          => $query,
92
        query          => $query,
(-)a/cataloguing/value_builder/unimarc_field_4XX.pl (-1 / +4 lines)
Lines 335-341 sub plugin { Link Here
335
        my $orderby;
335
        my $orderby;
336
        $search = 'kw,wrdl='.$search.' and mc-itemtype='.$itype if $itype;
336
        $search = 'kw,wrdl='.$search.' and mc-itemtype='.$itype if $itype;
337
        my ( $errors, $results, $total_hits ) = SimpleSearch($search, $startfrom * $resultsperpage, $resultsperpage );
337
        my ( $errors, $results, $total_hits ) = SimpleSearch($search, $startfrom * $resultsperpage, $resultsperpage );
338
        my $total = scalar(@$results);
338
        if (defined $errors ) {
339
            $results = [];
340
        }
341
        my $total = @{$results};
339
342
340
        #        warn " biblio count : ".$total;
343
        #        warn " biblio count : ".$total;
341
344
(-)a/labels/label-item-search.pl (-2 / +2 lines)
Lines 92-99 if ( $op eq "do_search" ) { Link Here
92
    ( $error, $marcresults, $total_hits ) =
92
    ( $error, $marcresults, $total_hits ) =
93
      SimpleSearch( $ccl_query, $offset, $resultsperpage );
93
      SimpleSearch( $ccl_query, $offset, $resultsperpage );
94
94
95
    if (scalar($marcresults) > 0) {
95
    if (!defined $error && @{$marcresults} ) {
96
        $show_results = scalar @$marcresults;
96
        $show_results = @{$marcresults};
97
    }
97
    }
98
    else {
98
    else {
99
        $debug and warn "ERROR label-item-search: no results from SimpleSearch";
99
        $debug and warn "ERROR label-item-search: no results from SimpleSearch";
(-)a/misc/migration_tools/bulkmarcimport.pl (-4 / +4 lines)
Lines 222-236 RECORD: while ( ) { Link Here
222
       my ($error, $results,$totalhits)=C4::Search::SimpleSearch( $query, 0, 3, [$server] );
222
       my ($error, $results,$totalhits)=C4::Search::SimpleSearch( $query, 0, 3, [$server] );
223
       die "unable to search the database for duplicates : $error" if (defined $error);
223
       die "unable to search the database for duplicates : $error" if (defined $error);
224
       #warn "$query $server : $totalhits";
224
       #warn "$query $server : $totalhits";
225
       if ($results && scalar(@$results)==1){
225
       if ( @{$results} == 1 ){
226
           my $marcrecord = MARC::File::USMARC::decode($results->[0]);
226
           my $marcrecord = MARC::File::USMARC::decode($results->[0]);
227
	   	   $id=GetRecordId($marcrecord,$tagid,$subfieldid);
227
	   	   $id=GetRecordId($marcrecord,$tagid,$subfieldid);
228
       } 
228
       } 
229
       elsif  ($results && scalar(@$results)>1){
229
       elsif  ( @{$results} > 1){
230
       $debug && warn "more than one match for $query";
230
           $debug && warn "more than one match for $query";
231
       } 
231
       } 
232
       else {
232
       else {
233
       $debug && warn "nomatch for $query";
233
           $debug && warn "nomatch for $query";
234
       }
234
       }
235
    }
235
    }
236
	my $originalid;
236
	my $originalid;
(-)a/misc/migration_tools/remove_unused_authorities.pl (+4 lines)
Lines 62-67 while (my $data=$rqselect->fetchrow_hashref){ Link Here
62
    $query= "an=".$data->{'authid'};
62
    $query= "an=".$data->{'authid'};
63
    # search for biblios mapped
63
    # search for biblios mapped
64
    my ($err,$res,$used) = C4::Search::SimpleSearch($query,0,10);
64
    my ($err,$res,$used) = C4::Search::SimpleSearch($query,0,10);
65
    if (defined $err) {
66
        warn "error: $err on search $query\n";
67
        next;
68
    }
65
    print ".";
69
    print ".";
66
    print "$counter\n" unless $counter++ % 100;
70
    print "$counter\n" unless $counter++ % 100;
67
    # if found, delete, otherwise, just count
71
    # if found, delete, otherwise, just count
(-)a/serials/subscription-bib-search.pl (-1 / +1 lines)
Lines 90-96 if ($op eq "do_search" && $query) { Link Here
90
    $resultsperpage = 20 if(!defined $resultsperpage);
90
    $resultsperpage = 20 if(!defined $resultsperpage);
91
91
92
    my ($error, $marcrecords, $total_hits) = SimpleSearch($query, $startfrom*$resultsperpage, $resultsperpage);
92
    my ($error, $marcrecords, $total_hits) = SimpleSearch($query, $startfrom*$resultsperpage, $resultsperpage);
93
    my $total = scalar @$marcrecords;
94
93
95
    if (defined $error) {
94
    if (defined $error) {
96
        $template->param(query_error => $error);
95
        $template->param(query_error => $error);
Lines 98-103 if ($op eq "do_search" && $query) { Link Here
98
        output_html_with_http_headers $input, $cookie, $template->output;
97
        output_html_with_http_headers $input, $cookie, $template->output;
99
        exit;
98
        exit;
100
    }
99
    }
100
    my $total = @{$marcrecords};
101
    my @results;
101
    my @results;
102
102
103
    for(my $i=0;$i<$total;$i++) {
103
    for(my $i=0;$i<$total;$i++) {
(-)a/t/lib/KohaTest.pm (-3 / +2 lines)
Lines 590-597 sub add_biblios { Link Here
590
590
591
    $self->reindex_marc();
591
    $self->reindex_marc();
592
    my $query = 'Finn Test';
592
    my $query = 'Finn Test';
593
    my ( $error, $results ) = SimpleSearch( $query );
593
    my ( $error, $results, undef ) = SimpleSearch( $query );
594
    if ( $param{'count'} <= scalar( @$results ) ) {
594
    if ( !defined $error && $param{'count'} <=  @{$results} ) {
595
        pass( "found all $param{'count'} titles" );
595
        pass( "found all $param{'count'} titles" );
596
    } else {
596
    } else {
597
        fail( "we never found all $param{'count'} titles" );
597
        fail( "we never found all $param{'count'} titles" );
598
- 

Return to bug 5415