From: Nick Clemens Date: Mon, 10 Jun 2019 18:54:30 +0000 (+0000) Subject: Bug 12537: Don't retrieve XISBN results for the same biblionumber X-Git-Url: http://git.equinoxoli.org/?p=koha-equinox.git;a=commitdiff_plain;h=fd5686b156ceb10958cab728b7695aa2b39b9933 Bug 12537: Don't retrieve XISBN results for the same biblionumber For a biblio with multiple ISBNS we sometimes get our own record back when check XISBN, we should test for this To test: 1 - Edit a record in the catalogue, add two isbns: 0521240670 0521284198 2 - Enable ThingISBN and FRBRizeEditions and OPACFRBRizeEditions 3 - View the record in staff and OPAC 4 - You should see editions tab pointing to the same record 5 - Apply patch 6 - Reload the record details, you should no longer see editions tab 7 - Add the second ISBN to another record 8 - Reload details for original record, you shoudl see editions linking to the record with second ISBN 9 - prove -v t/db_dependent/XISBN.t NOTE: Current tests don't work under elasticsearch, but the code does, tests should be rewritten on another bug Signed-off-by: Mark Tompsett Signed-off-by: Bouzid Fergani Signed-off-by: Arthur Bousquet Signed-off-by: Katrin Fischer Signed-off-by: Martin Renvoize --- diff --git a/C4/XISBN.pm b/C4/XISBN.pm index 22b4502..1b3a3bb 100644 --- a/C4/XISBN.pm +++ b/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); diff --git a/catalogue/detail.pl b/catalogue/detail.pl index 027ca52..b7e4d6e 100755 --- a/catalogue/detail.pl +++ b/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 $@"; } diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index 7767bfa..8f044f5 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -918,7 +918,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 $@"; } diff --git a/t/db_dependent/XISBN.t b/t/db_dependent/XISBN.t index 803743a..500bb6d 100755 --- a/t/db_dependent/XISBN.t +++ b/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