Bug 11175: (follow-up) Return empty array if no components
Signed-off-by: Nick Clemens <nick@bywatersolutions.com> Signed-off-by: Pasi Kallinen <pasi.kallinen@koha-suomi.fi> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Andrew Nugged <nugged@gmail.com> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
parent
7969358765
commit
9b09b2558b
1 changed files with 19 additions and 21 deletions
|
@ -492,33 +492,31 @@ sub components {
|
|||
|
||||
return if (C4::Context->preference('marcflavour') ne 'MARC21');
|
||||
|
||||
if (!defined($self->{_components})) {
|
||||
my $marc = C4::Biblio::GetMarcBiblio({ biblionumber => $self->id });
|
||||
my $pf001 = $marc->field('001') || undef;
|
||||
my $searcher = Koha::SearchEngine::Search->new({index => $Koha::SearchEngine::BIBLIOS_INDEX});
|
||||
my $marc = C4::Biblio::GetMarcBiblio({ biblionumber => $self->id });
|
||||
my $pf001 = $marc->field('001') || undef;
|
||||
my $searcher = Koha::SearchEngine::Search->new({index => $Koha::SearchEngine::BIBLIOS_INDEX});
|
||||
|
||||
if (defined($pf001)) {
|
||||
my $pf003 = $marc->field('003') || undef;
|
||||
my $searchstr;
|
||||
if (defined($pf001)) {
|
||||
my $pf003 = $marc->field('003') || undef;
|
||||
my $searchstr;
|
||||
|
||||
if (!defined($pf003)) {
|
||||
# search for 773$w='Host001'
|
||||
$searchstr = "rcn='".$pf001->data()."'";
|
||||
} else {
|
||||
# search for (773$w='Host001' and 003='Host003') or 773$w='Host003 Host001')
|
||||
$searchstr = "(rcn='".$pf001->data()."' and cni='".$pf003->data()."')";
|
||||
$searchstr .= " or rcn='".$pf003->data()." ".$pf001->data()."'";
|
||||
}
|
||||
|
||||
my ( $errors, $results, $total_hits ) = $searcher->simple_search_compat( $searchstr, 0, undef );
|
||||
|
||||
$self->{_components} = $results if ( defined($results) && scalar(@$results) );
|
||||
if (!defined($pf003)) {
|
||||
# search for 773$w='Host001'
|
||||
$searchstr = "rcn='".$pf001->data()."'";
|
||||
} else {
|
||||
warn "Record $self->id has no 001";
|
||||
# search for (773$w='Host001' and 003='Host003') or 773$w='Host003 Host001')
|
||||
$searchstr = "(rcn='".$pf001->data()."' and cni='".$pf003->data()."')";
|
||||
$searchstr .= " or rcn='".$pf003->data()." ".$pf001->data()."'";
|
||||
}
|
||||
|
||||
my ( $errors, $results, $total_hits ) = $searcher->simple_search_compat( $searchstr, 0, undef );
|
||||
|
||||
$self->{_components} = $results if ( defined($results) && scalar(@$results) );
|
||||
} else {
|
||||
warn "Record $self->id has no 001";
|
||||
}
|
||||
|
||||
return $self->{_components};
|
||||
return $self->{_components} || ();
|
||||
}
|
||||
|
||||
=head3 subscriptions
|
||||
|
|
Loading…
Reference in a new issue