Bug 29319: Use Business::ISBN to check ISBNs on addbooks.pl/cataloging search

To test:
1. Go to cataloging search and enter something like "7th Heaven".
2. Get an error when searching, Koha thinks you entered an ISBN
3. Apply patch
4. Try the same search, it should be a proper title search now
5. Find some stuff in the catalog with ISBN numbers in them.
6. The search should properly return ISBN13/ISBN10 searches, without with out the '-'.

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
(cherry picked from commit 14c8d4c230)
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
This commit is contained in:
Lucas Gass 2021-10-25 22:52:22 +00:00 committed by Victor Grousset/tuxayo
parent b1fec5be3e
commit 5d86cc7363
1 changed files with 5 additions and 12 deletions

View File

@ -40,6 +40,7 @@ use Koha::BiblioFrameworks;
use Koha::SearchEngine::Search;
use Koha::SearchEngine::QueryBuilder;
use Koha::Z3950Servers;
use Business::ISBN;
my $input = CGI->new;
@ -108,19 +109,11 @@ if ($query) {
my $countbr = 0;
my @resultsbr;
if ($query) {
# fill isbn or title, depending on what has been entered
#u must do check on isbn because u can find number in beginning of title
#check is on isbn legnth 13 for new isbn and 10 for old isbn
my ( $title, $isbn );
if ($query=~/\d/) {
my $clean_query = $query;
$clean_query =~ s/-//g; # remove hyphens
my $querylength = length $clean_query;
if ( $querylength == 13 || $querylength == 10 ) {
$isbn = $query;
}
}
if (!$isbn) {
my $isbn_valid = Business::ISBN->new($query);
if ( $isbn_valid && $isbn_valid->is_valid() ) {
$isbn = $query;
} else {
$title = $query;
}
( $countbr, @resultsbr ) = BreedingSearch( $title, $isbn );