Bugzilla – Attachment 157398 Details for
Bug 35099
Cannot load records with invalid marcxml
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35099: Defensive coding for bad MARC21 records
Bug-35099-Defensive-coding-for-bad-MARC21-records.patch (text/plain), 2.25 KB, created by
Martin Renvoize (ashimema)
on 2023-10-19 08:51:01 UTC
(
hide
)
Description:
Bug 35099: Defensive coding for bad MARC21 records
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2023-10-19 08:51:01 UTC
Size:
2.25 KB
patch
obsolete
>From b6c58cd5580fbda6ba0000ebab02fbd12acdf0c4 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Thu, 19 Oct 2023 09:28:23 +0100 >Subject: [PATCH] Bug 35099: Defensive coding for bad MARC21 records > >This patch modernises the get_marc_volumes method to match the form of >get_marc_components. The original code was submitted around a similar >time but didn't get the modernisations introduced since. > >We remove the original localised caching as well as putting an eval >around the search_simple_compat call to prevent crashes on bad marc >records found in the database. >--- > Koha/Biblio.pm | 25 ++++++++++++++++++------- > 1 file changed, 18 insertions(+), 7 deletions(-) > >diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm >index 9e2386ae986..fc38955718c 100644 >--- a/Koha/Biblio.pm >+++ b/Koha/Biblio.pm >@@ -728,20 +728,31 @@ this object (MARC21 773$w or 8xx$w point to this) > sub get_marc_volumes { > my ( $self, $max_results ) = @_; > >- return $self->{_volumes} if defined( $self->{_volumes} ); >+ return [] if ( C4::Context->preference('marcflavour') ne 'MARC21' ); > > my $searchstr = $self->get_volumes_query; > >+ my $volumes; > if ( defined($searchstr) ) { > my $searcher = Koha::SearchEngine::Search->new( { index => $Koha::SearchEngine::BIBLIOS_INDEX } ); >- my ( $errors, $results, $total_hits ) = $searcher->simple_search_compat( $searchstr, 0, $max_results ); >- $self->{_volumes} = >- ( defined($results) && scalar(@$results) ) ? $results : []; >- } else { >- $self->{_volumes} = []; >+ my ( $error, $results, $total_hits ); >+ eval { ( $error, $results, $total_hits ) = $searcher->simple_search_compat( $searchstr, 0, $max_results ); }; >+ if ( $error || $@ ) { >+ $error //= q{}; >+ $error .= $@ if $@; >+ warn "Warning from search_compat: '$error'"; >+ $self->add_message( >+ { >+ type => 'error', >+ message => 'volume_search', >+ payload => $error, >+ } >+ ); >+ } >+ $volumes = ( defined($results) && scalar(@$results) ) ? $results : []; > } > >- return $self->{_volumes}; >+ return $volumes // []; > } > > =head2 get_volumes_query >-- >2.41.0
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 35099
:
157394
|
157398
|
157423
|
157430
|
157431
|
157432
|
157510
|
157513
|
157515