[Koha-patches] [PATCH] Bug 4305 Follow up Ian patch
Frédéric Demians
f.demians at tamil.fr
Wed Oct 6 19:35:22 CEST 2010
Retain the first valid ISBN--if multiple ISBN are stored in
biblioitems.isbn--from Business::ISBN perspective.
---
C4/Koha.pm | 23 ++++++++++++++---------
1 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/C4/Koha.pm b/C4/Koha.pm
index ab9131a..6baf97b 100644
--- a/C4/Koha.pm
+++ b/C4/Koha.pm
@@ -1242,9 +1242,6 @@ sub GetNormalizedISBN {
my ($isbn,$record,$marcflavour) = @_;
my @fields;
if ($isbn) {
- # Koha attempts to store multiple ISBNs in biblioitems.isbn, separated by " | "
- # anything after " | " should be removed, along with the delimiter
- $isbn =~ s/(.*)( \| )(.*)/$1/;
return _isbn_cleanup($isbn);
}
return undef unless $record;
@@ -1327,12 +1324,20 @@ sub _normalize_match_point {
}
sub _isbn_cleanup ($) {
- my $isbn = Business::ISBN->new( shift );
- return undef unless $isbn;
- $isbn = $isbn->as_isbn10 if $isbn->type eq 'ISBN13';
- $isbn = $isbn->as_string;
- $isbn =~ s/-//g;
- return $isbn;
+ my $isbns = shift;
+ return undef unless $isbns;
+
+ # Koha attempts to store multiple ISBNs in biblioitems.isbn, separated by
+ # |. We retain the first valid ISBN
+ for my $isbn ( split /\|/, $isbns ) {
+ $isbn = Business::ISBN->new( $isbn );
+ next unless $isbn;
+ $isbn = $isbn->as_isbn10 if $isbn->type eq 'ISBN13';
+ $isbn = $isbn->as_string;
+ $isbn =~ s/-//g;
+ return $isbn;
+ }
+ return undef;
}
1;
--
1.7.1
More information about the Koha-patches
mailing list