From 23a060274b98e340bdfa67509ad0a586dfde01a9 Mon Sep 17 00:00:00 2001 From: Jesse Weaver Date: Fri, 15 Jan 2016 14:56:45 -0700 Subject: [PATCH] Bug 18823: Rancor - improve import batch search/update ISBN handling --- C4/ImportBatch.pm | 6 ++---- Koha/MetaSearcher.pm | 11 ++++++++++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/C4/ImportBatch.pm b/C4/ImportBatch.pm index 1f47a14..de72b13 100644 --- a/C4/ImportBatch.pm +++ b/C4/ImportBatch.pm @@ -1655,11 +1655,9 @@ sub _update_biblio_fields { my ($title, $author, $isbn, $issn) = _parse_biblio_fields($marc_record); my $dbh = C4::Context->dbh; - # FIXME no controlnumber, originalsource + # FIXME no originalsource # FIXME 2 - should regularize normalization of ISBN wherever it is done - $isbn =~ s/\(.*$//; - $isbn =~ tr/ -_//; - $isbn = uc $isbn; + $isbn = C4::Koha::GetNormalizedISBN($isbn); my $sth = $dbh->prepare("UPDATE import_biblios SET title = ?, author = ?, isbn = ?, issn = ? WHERE import_record_id = ?"); $sth->execute($title, $author, $isbn, $issn, $import_record_id); diff --git a/Koha/MetaSearcher.pm b/Koha/MetaSearcher.pm index 366e98b..1cac8af 100644 --- a/Koha/MetaSearcher.pm +++ b/Koha/MetaSearcher.pm @@ -22,6 +22,7 @@ use Modern::Perl; use base 'Class::Accessor'; use C4::Charset qw( MarcToUTF8Record ); +use C4::Koha qw(); # Purely for GetNormalizedISBN use C4::Search qw(); # Purely for new_record_from_zebra use DBIx::Class::ResultClass::HashRefInflator; use IO::Select; @@ -238,8 +239,16 @@ sub _db_query_get_match_conditions { if ( $value =~ /\*/ ) { $value =~ s/\*/%/; return { -like => $value }; + } elsif ( $index eq 'isbn' ) { + return C4::Koha::GetNormalizedISBN($value) || $value; } elsif ( $_batch_db_text_columns->{$index} ) { - return map +{ -regexp => '[[:<:]]' . $_ . '[[:>:]]' }, split( /\s+/, $value ); + my $stripped_value = $value; + $stripped_value =~ s/[^\w ]//g; + $stripped_value =~ s/^ +| +$//g; + + return $value if ( !$stripped_value ); + + return map +{ -regexp => '[[:<:]]' . $_ . '[[:>:]]' }, split( /\s+/, $stripped_value ); } else { return $value; } -- 2.1.4