From 70794ed26c46ecc17fa9a48931abb2eedc0d3c7b Mon Sep 17 00:00:00 2001 From: Mark Tompsett Date: Fri, 5 Jun 2015 20:31:51 -0400 Subject: [PATCH] Bug 14287: counter-patch to preserve valid ISBN-13 not starting with 978 Since the issue is for ISBN-13 to ISBN-10 of non-978 ISBN-13 values, this patch only modifies the ISBN-10 case. Additionally, since ISBN-13 always returns a value, this patch means the return unless is no longer needed. Flooding the error log seems unnecessary. TEST PLAN --------- 1) prove -v t/Koha.t 2) apply patch 3) prove -v t/Koha.t -- note that test 17 has been changed. 4) run koha qa test tools --- C4/Koha.pm | 4 ++-- t/Koha.t | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/C4/Koha.pm b/C4/Koha.pm index 4f54a3b..a6f7d23 100644 --- a/C4/Koha.pm +++ b/C4/Koha.pm @@ -1720,12 +1720,12 @@ sub NormalizeISBN { if ( $isbn && $isbn->is_valid() ) { if ( $format eq 'ISBN-10' ) { - $isbn = $isbn->as_isbn10(); + my $isbn10 = $isbn->as_isbn10(); + $isbn = $isbn10 if $isbn10; } elsif ( $format eq 'ISBN-13' ) { $isbn = $isbn->as_isbn13(); } - return unless $isbn; if ($strip_hyphens) { $string = $isbn->as_string( [] ); diff --git a/t/Koha.t b/t/Koha.t index 933fd5b..2482b0d 100755 --- a/t/Koha.t +++ b/t/Koha.t @@ -93,7 +93,7 @@ eval { $isbn = C4::Koha::NormalizeISBN({ isbn => '979-10-90085-00-8', format => 'ISBN-10', strip_hyphens => 1 }); }; ok($@ eq '', 'NormalizeISBN does not throw exception when converting to ISBN10 an ISBN starting with 979 (bug 13167)'); -ok(!defined $isbn, 'NormalizeISBN returns undef when converting to ISBN10 an ISBN starting with 979 (bug 13167)'); +ok($isbn eq '9791090085008', 'NormalizeISBN returns ISBN13 when converting to ISBN10 an ISBN starting with 979 (bug 14287)'); @isbns = GetVariationsOfISBNs('abc'); is(scalar(@isbns), 0, 'zero variations returned of invalid ISBN'); -- 2.1.4