[Koha-bugs] [Bug 14287] Preserve valid ISBN-13 identifiers if they start with something else than 978

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Sat Jun 6 02:19:40 CEST 2015


http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14287

--- Comment #3 from M. Tompsett <mtompset at hotmail.com> ---
Comment on attachment 39625
  --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=39625
Bug 14287 - Preserve valid ISBN-13 identifiers if they start with something
else than 978

Review of attachment 39625:
 --> (http://bugs.koha-community.org/bugzilla3/page.cgi?id=splinter.html&bug=14287&attachment=39625)
-----------------------------------------------------------------

::: C4/Koha.pm
@@ +1725,4 @@
>          elsif ( $format eq 'ISBN-13' ) {
>              $isbn = $isbn->as_isbn13();
>          }
> +        unless ($isbn) { #If we cannot force the ISBN to another type, atleast prevent Koha from crashing by recovering some ISBN.

unless is hard to read, and if (!$isbn) is shorter.
Though, I don't think then as_isbn13() will return undef.
Only the as_isbn10() will:
"If it is an ISBN-13 with the prefix 978, it returns the ISBN-10 equivalent.
For all other cases it returns undef." (CPAN page)
So, why not:
            my $isbn10 = $isbn->as_isbn10();
            $isbn = $isbn10 if $isbn10;
in the ISBN-10 check?

@@ +1725,5 @@
>          elsif ( $format eq 'ISBN-13' ) {
>              $isbn = $isbn->as_isbn13();
>          }
> +        unless ($isbn) { #If we cannot force the ISBN to another type, atleast prevent Koha from crashing by recovering some ISBN.
> +            $isbn = Business::ISBN->new($string); #If we fail to force the ISBN to the given format, revert to the format we can infer.

Why rebuild something when we could simplify as I suggested above?

@@ +1726,5 @@
>              $isbn = $isbn->as_isbn13();
>          }
> +        unless ($isbn) { #If we cannot force the ISBN to another type, atleast prevent Koha from crashing by recovering some ISBN.
> +            $isbn = Business::ISBN->new($string); #If we fail to force the ISBN to the given format, revert to the format we can infer.
> +            warn "C4::Koha::NormalizeISBN():> Couldn't change ISBN '$string' to type '$format'. Using the inferred type '".$isbn->type()."' instead.";

Do we need to flood the error logs? Reports could be used to find those ISBN-13
entries with non-978 beginnings.

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list