@@ -, +, @@ biblionumber 0521240670 0521284198 --- C4/XISBN.pm | 6 +++--- catalogue/detail.pl | 2 +- opac/opac-detail.pl | 2 +- t/db_dependent/XISBN.t | 20 +++++++++++++++++++- 4 files changed, 24 insertions(+), 6 deletions(-) --- a/C4/XISBN.pm +++ a/C4/XISBN.pm @@ -72,14 +72,14 @@ sub _get_biblio_from_xisbn { return $biblio; } -=head1 get_xisbns($isbn); +=head1 get_xisbns($isbn, $biblionumber); =head2 $isbn is an ISBN string =cut sub get_xisbns { - my ( $isbn ) = @_; + my ( $isbn, $biblionumber ) = @_; my ($response,$thing_response,$syndetics_response,$errors); # THINGISBN if ( C4::Context->preference('ThingISBN') ) { @@ -107,7 +107,7 @@ sub get_xisbns { next if $unique_xisbns->{ $response_data->{content} }; $unique_xisbns->{ $response_data->{content} }++; my $xbiblio= _get_biblio_from_xisbn($response_data->{content}); - push @xisbns, $xbiblio if $xbiblio; + push @xisbns, $xbiblio if $xbiblio && $xbiblio->{biblionumber} ne $biblionumber; } if ( wantarray ) { return (\@xisbns, $errors); --- a/catalogue/detail.pl +++ a/catalogue/detail.pl @@ -461,7 +461,7 @@ if (C4::Context->preference("virtualshelves") ) { if (C4::Context->preference("FRBRizeEditions")==1) { eval { $template->param( - XISBNS => scalar get_xisbns($isbn) + XISBNS => scalar get_xisbns($isbn, $biblionumber) ); }; if ($@) { warn "XISBN Failed $@"; } --- a/opac/opac-detail.pl +++ a/opac/opac-detail.pl @@ -919,7 +919,7 @@ if (C4::Context->preference("virtualshelves") ) { if (C4::Context->preference("OPACFRBRizeEditions")==1) { eval { $template->param( - XISBNS => scalar get_xisbns($isbn) + XISBNS => scalar get_xisbns($isbn, $biblionumber) ); }; if ($@) { warn "XISBN Failed $@"; } --- a/t/db_dependent/XISBN.t +++ a/t/db_dependent/XISBN.t @@ -5,7 +5,7 @@ use Modern::Perl; -use Test::More tests => 3; +use Test::More tests => 5; use MARC::Record; use C4::Biblio; use C4::XISBN; @@ -62,6 +62,24 @@ SKIP: { "Gets correct biblionumber from a book with a similar isbn using ThingISBN." ); } +eval { $results_thingisbn = C4::XISBN::get_xisbns($isbn1,$biblionumber1); }; +SKIP: { + skip "Problem retrieving ThingISBN", 1 + unless $@ eq ''; + is( $results_thingisbn->[0]->{biblionumber}, + $biblionumber3, + "Gets correct biblionumber from a different book with a similar isbn using ThingISBN." ); +} + +eval { $results_thingisbn = C4::XISBN::get_xisbns($isbn1,$biblionumber3); }; +SKIP: { + skip "Problem retrieving ThingISBN", 1 + unless $@ eq ''; + is( $results_thingisbn->[0]->{biblionumber}, + undef, + "Doesn't get biblionumber if the biblionumber matches the one passed to the sub." ); +} + # Util subs # Add new biblio with isbn and return biblionumber --