Bugzilla – Attachment 127513 Details for
Bug 29437
500 error when performing a catalog search for an ISBN13 with no valid ISBN10
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29437: Search reservoir for term as title, author, or variations of ISBN
Bug-29437-Search-reservoir-for-term-as-title-autho.patch (text/plain), 4.06 KB, created by
Nick Clemens (kidclamp)
on 2021-11-10 13:48:02 UTC
(
hide
)
Description:
Bug 29437: Search reservoir for term as title, author, or variations of ISBN
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2021-11-10 13:48:02 UTC
Size:
4.06 KB
patch
obsolete
>From e3d506741bac14cafd90bd0585f1395a5d5d43d2 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Mon, 8 Nov 2021 19:24:36 +0000 >Subject: [PATCH] Bug 29437: Search reservoir for term as title, author, or > variations of ISBN > >The code in the script and the module attempt to determine whether a term is an isbn, or not. Rather >than try to do this, we can simply search it on the three fields: isbn, title, author > >Additionally, we should search as any of the ISBN variations to broaden our matches > >Note: Curently only an ISBN 10 is stored in import biblios, so for an ISBN13 that doesn't convert >the value will be blank - this is another bug > >To test: >1 - Perform a cataloging search for a valid ISBN 13 with no ISBN10 counterpart: > 9798200834976 >2 - 500 error >3 - Apply patch >4 - Repeat, no results >5 - Import some records >6 - Search by title/author/isbn >7 - Confirm searching works as expected > >WNC amended to fix spelling > >Signed-off-by: David Nind <david@davidnind.com> >--- > C4/Breeding.pm | 30 ++++++++++-------------------- > cataloguing/addbooks.pl | 9 +-------- > 2 files changed, 11 insertions(+), 28 deletions(-) > >diff --git a/C4/Breeding.pm b/C4/Breeding.pm >index 75f47c668a..95f1b87468 100644 >--- a/C4/Breeding.pm >+++ b/C4/Breeding.pm >@@ -22,7 +22,7 @@ use strict; > use warnings; > > use C4::Biblio; >-use C4::Koha qw( GetNormalizedISBN ); >+use C4::Koha qw( GetVariationsOfISBNs ); > use C4::Charset qw( MarcToUTF8Record SetUTF8Flag ); > use MARC::File::USMARC; > use MARC::Field; >@@ -56,9 +56,8 @@ cataloguing reservoir features. > > =head2 BreedingSearch > >-($count, @results) = &BreedingSearch($title,$isbn); >-C<$title> contains the title, >-C<$isbn> contains isbn or issn, >+($count, @results) = &BreedingSearch($term); >+C<$term> contains the term to search, it will be searched as title,author, or isbn > > C<$count> is the number of items in C<@results>. C<@results> is an > array of references-to-hash; the keys are the items from the C<import_records> and >@@ -67,34 +66,25 @@ C<import_biblios> tables of the Koha database. > =cut > > sub BreedingSearch { >- my ($search,$isbn) = @_; >+ my ($term) = @_; > my $dbh = C4::Context->dbh; > my $count = 0; > my ($query,@bind); > my $sth; > my @results; > >+ my $authortitle = $term; >+ $authortitle =~ s/(\s+)/\%/g; #Replace spaces with wildcard >+ $authortitle = "%" . $authortitle . "%"; #Add wildcard to start and end of string > # normalise ISBN like at import >- $isbn = C4::Koha::GetNormalizedISBN($isbn); >+ my @isbns = C4::Koha::GetVariationsOfISBNs($term); > > $query = "SELECT import_record_id, file_name, isbn, title, author > FROM import_biblios > JOIN import_records USING (import_record_id) > JOIN import_batches USING (import_batch_id) >- WHERE "; >- @bind=(); >- if (defined($search) && length($search)>0) { >- $search =~ s/(\s+)/\%/g; >- $query .= "title like ? OR author like ?"; >- push(@bind,"%$search%", "%$search%"); >- } >- if ($#bind!=-1 && defined($isbn) && length($isbn)>0) { >- $query .= " and "; >- } >- if (defined($isbn) && length($isbn)>0) { >- $query .= "isbn like ?"; >- push(@bind,"$isbn%"); >- } >+ WHERE title LIKE ? OR author LIKE ? OR isbn IN (" . join(',',('?') x @isbns) . ")"; >+ @bind=( $authortitle, $authortitle, @isbns ); > $sth = $dbh->prepare($query); > $sth->execute(@bind); > while (my $data = $sth->fetchrow_hashref) { >diff --git a/cataloguing/addbooks.pl b/cataloguing/addbooks.pl >index 079d477b15..8302141431 100755 >--- a/cataloguing/addbooks.pl >+++ b/cataloguing/addbooks.pl >@@ -106,14 +106,7 @@ if ($query) { > my $countbr = 0; > my @resultsbr; > if ($query) { >- my ( $title, $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 ); >+ ( $countbr, @resultsbr ) = BreedingSearch( $query ); > } > my $breeding_loop = []; > for my $resultsbr (@resultsbr) { >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 29437
:
127458
|
127460
|
127512
|
127513
|
127516
|
127517
|
127842
|
127843
|
127844
|
127845