From 774483772b2a7ff8ebdb8a9aeac82881e7c858cf Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Mon, 10 Mar 2014 11:52:19 -0300 Subject: [PATCH] Bug 11912: (refactoring followup) make GetMarcISBN implement its advertised API The current implementation of GetMarcISBN contradicts the documented API. It currently returns an array of hashes with only one key (marcisbn) which doesn't add any value to it. I chose to fix GetMarcISBN to honour the API instead of changing thex docs, because it seems a really silly change. To test: - Run: prove t/db_dependent/Biblio.t => SUCCESS - catalogue/detail.pl should correctly show ISBNs. - opac/opac-detail.pl should correctly show ISBNs in both prog and bootstrap. - opac-opac-sendshelf.pl should correctly show ISBNs in the email. Sponsored-by: Universidad Nacional de Cordoba Signed-off-by: Nicolas Legrand Signed-off-by: Jonathan Druart Signed-off-by: Galen Charlton --- C4/Biblio.pm | 5 ++--- koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt | 2 +- koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt | 2 +- koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-sendshelf.tt | 2 +- koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt | 2 +- koha-tmpl/opac-tmpl/prog/en/modules/opac-sendshelf.tt | 2 +- t/db_dependent/Biblio.t | 5 ++--- 7 files changed, 9 insertions(+), 11 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index a34e5b6042..61e4c3b9a6 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -1689,13 +1689,12 @@ sub GetMarcISBN { } else { # assume marc21 if not unimarc $scope = '020'; } + my @marcisbns; - my $marcisbn; foreach my $field ( $record->field($scope) ) { my $isbn = $field->as_string(); if ( $isbn ne "" ) { - $marcisbn = { marcisbn => $isbn, }; - push @marcisbns, $marcisbn; + push @marcisbns, $isbn; } } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt index d09a3c452a..a38768ab4a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -416,7 +416,7 @@ function verify_images() {
    [% IF ( MARCISBNS ) %] -
  • ISBN:
      [% FOREACH MARCISBN IN MARCISBNS %]
    • [% MARCISBN.marcisbn %]
    • [% END %]
  • +
  • ISBN:
      [% FOREACH MARCISBN IN MARCISBNS %]
    • [% MARCISBN %]
    • [% END %]
  • [% ELSE %] [% IF ( normalized_isbn ) %]
  • ISBN: [% normalized_isbn %]
  • diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt index 6afb2407d1..4abf17e7dd 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt @@ -197,7 +197,7 @@ [% END %] [% IF ( MARCISBNS ) %] - ISBN:[% FOREACH MARCISBN IN MARCISBNS %][% MARCISBN.marcisbn %][% IF ( loop.last ) %].[% ELSE %]; [% END %][% END %] + ISBN:[% FOREACH MARCISBN IN MARCISBNS %][% MARCISBN %][% IF ( loop.last ) %].[% ELSE %]; [% END %][% END %] [% ELSE %] [% IF ( normalized_isbn ) %] ISBN: [% normalized_isbn %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-sendshelf.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-sendshelf.tt index c13a6593bb..f3c7ed788d 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-sendshelf.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-sendshelf.tt @@ -59,7 +59,7 @@ Your list : [% shelfname %] [% IF ( BIBLIO_RESULT.ISBN && BIBLIO_RESULT.size > 0 ) %] ISBN: [% FOREACH isbn IN BIBLIO_RESULT.ISBN %] - [% isbn.marcisbn %] + [% isbn %] [% UNLESS ( loop.last ) %]; [% END %] [% END %]
    diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt index fce873cb2c..7ffbbd082f 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt @@ -651,7 +651,7 @@ YAHOO.util.Event.onContentReady("furtherm", function () { [% IF ( pages ) %]Physical details: [% pages %] [% illus %] [% size %][% END %] [% IF ( MARCISBNS ) %] - ISBN:[% FOREACH MARCISBN IN MARCISBNS %][% MARCISBN.marcisbn %][% IF ( loop.last ) %].[% ELSE %]; [% END %][% END %] + ISBN:[% FOREACH MARCISBN IN MARCISBNS %][% MARCISBN %][% IF ( loop.last ) %].[% ELSE %]; [% END %][% END %] [% ELSE %] [% IF ( normalized_isbn ) %] ISBN: [% normalized_isbn %] diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-sendshelf.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-sendshelf.tt index c13a6593bb..f3c7ed788d 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-sendshelf.tt +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-sendshelf.tt @@ -59,7 +59,7 @@ Your list : [% shelfname %] [% IF ( BIBLIO_RESULT.ISBN && BIBLIO_RESULT.size > 0 ) %] ISBN: [% FOREACH isbn IN BIBLIO_RESULT.ISBN %] - [% isbn.marcisbn %] + [% isbn %] [% UNLESS ( loop.last ) %]; [% END %] [% END %]
    diff --git a/t/db_dependent/Biblio.t b/t/db_dependent/Biblio.t index 2dd80348f3..b861023704 100755 --- a/t/db_dependent/Biblio.t +++ b/t/db_dependent/Biblio.t @@ -19,7 +19,6 @@ use Modern::Perl; use Test::More tests => 3; use Test::MockModule; -use Data::Dumper; use MARC::Record; @@ -166,7 +165,7 @@ sub run_tests { $record_for_isbn->append_fields( $isbn_field ); $isbns = GetMarcISBN( $record_for_isbn, $marcflavour ); is( scalar @$isbns, 1, '(GetMarcISBN) The record contains one ISBN'); - is( $isbns->[0]->{ marcisbn }, $isbn, '(GetMarcISBN) The record contains our ISBN'); + is( $isbns->[0], $isbn, '(GetMarcISBN) The record contains our ISBN'); # We add 3 more ISBNs $record_for_isbn = MARC::Record->new(); @@ -178,7 +177,7 @@ sub run_tests { $isbns = GetMarcISBN( $record_for_isbn, $marcflavour ); is( scalar @$isbns, 4, '(GetMarcISBN) The record contains 4 ISBNs'); for my $i (0 .. $#more_isbns) { - is( $isbns->[$i]->{ marcisbn }, $more_isbns[$i], + is( $isbns->[$i], $more_isbns[$i], "(GetMarcISBN) Corretly retrieves ISBN #". ($i + 1)); } -- 2.39.5