View | Details | Raw Unified | Return to bug 14287
Collapse All | Expand All

(-)a/C4/Koha.pm (-1 / +4 lines)
Lines 1725-1731 sub NormalizeISBN { Link Here
1725
        elsif ( $format eq 'ISBN-13' ) {
1725
        elsif ( $format eq 'ISBN-13' ) {
1726
            $isbn = $isbn->as_isbn13();
1726
            $isbn = $isbn->as_isbn13();
1727
        }
1727
        }
1728
        return unless $isbn;
1728
        unless ($isbn) { #If we cannot force the ISBN to another type, atleast prevent Koha from crashing by recovering some ISBN.
1729
            $isbn = Business::ISBN->new($string); #If we fail to force the ISBN to the given format, revert to the format we can infer.
1730
            warn "C4::Koha::NormalizeISBN():> Couldn't change ISBN '$string' to type '$format'. Using the inferred type '".$isbn->type()."' instead.";
1731
        }
1729
1732
1730
        if ($strip_hyphens) {
1733
        if ($strip_hyphens) {
1731
            $string = $isbn->as_string( [] );
1734
            $string = $isbn->as_string( [] );
(-)a/t/Koha.t (-2 / +1 lines)
Lines 93-99 eval { Link Here
93
    $isbn = C4::Koha::NormalizeISBN({ isbn => '979-10-90085-00-8', format => 'ISBN-10', strip_hyphens => 1 });
93
    $isbn = C4::Koha::NormalizeISBN({ isbn => '979-10-90085-00-8', format => 'ISBN-10', strip_hyphens => 1 });
94
};
94
};
95
ok($@ eq '', 'NormalizeISBN does not throw exception when converting to ISBN10 an ISBN starting with 979 (bug 13167)');
95
ok($@ eq '', 'NormalizeISBN does not throw exception when converting to ISBN10 an ISBN starting with 979 (bug 13167)');
96
ok(!defined $isbn, 'NormalizeISBN returns undef when converting to ISBN10 an ISBN starting with 979 (bug 13167)');
96
ok($isbn eq "9791090085008", 'NormalizeISBN returns ISBN-13 when converting to ISBN10 an ISBN starting with 979 (bug 14287)');
97
97
98
@isbns = GetVariationsOfISBNs('abc');
98
@isbns = GetVariationsOfISBNs('abc');
99
is(scalar(@isbns), 0, 'zero variations returned of invalid ISBN');
99
is(scalar(@isbns), 0, 'zero variations returned of invalid ISBN');
100
- 

Return to bug 14287