@@ -, +, @@ --- Koha/Biblio.pm | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) --- a/Koha/Biblio.pm +++ a/Koha/Biblio.pm @@ -728,20 +728,31 @@ this object (MARC21 773$w or 8xx$w point to this) sub get_marc_volumes { my ( $self, $max_results ) = @_; - return $self->{_volumes} if defined( $self->{_volumes} ); + return [] if ( C4::Context->preference('marcflavour') ne 'MARC21' ); my $searchstr = $self->get_volumes_query; + my $volumes; if ( defined($searchstr) ) { my $searcher = Koha::SearchEngine::Search->new( { index => $Koha::SearchEngine::BIBLIOS_INDEX } ); - my ( $errors, $results, $total_hits ) = $searcher->simple_search_compat( $searchstr, 0, $max_results ); - $self->{_volumes} = - ( defined($results) && scalar(@$results) ) ? $results : []; - } else { - $self->{_volumes} = []; + my ( $error, $results, $total_hits ); + eval { ( $error, $results, $total_hits ) = $searcher->simple_search_compat( $searchstr, 0, $max_results ); }; + if ( $error || $@ ) { + $error //= q{}; + $error .= $@ if $@; + warn "Warning from search_compat: '$error'"; + $self->add_message( + { + type => 'error', + message => 'volume_search', + payload => $error, + } + ); + } + $volumes = ( defined($results) && scalar(@$results) ) ? $results : []; } - return $self->{_volumes}; + return $volumes // []; } =head2 get_volumes_query --