Bugzilla – Attachment 128485 Details for
Bug 29690
Software error in details.pl when invalid MARCXML
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29690: Add eval on metadata record fetch in details.pl when invalid MARCXML
Bug-29690-Add-eval-on-metadata-record-fetch-in-det.patch (text/plain), 2.91 KB, created by
Martin Renvoize (ashimema)
on 2021-12-14 08:14:10 UTC
(
hide
)
Description:
Bug 29690: Add eval on metadata record fetch in details.pl when invalid MARCXML
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2021-12-14 08:14:10 UTC
Size:
2.91 KB
patch
obsolete
>From fc6e746a72852e2b971f37ac1dd6dc9ae8b80a98 Mon Sep 17 00:00:00 2001 >From: Fridolin Somers <fridolin.somers@biblibre.com> >Date: Mon, 13 Dec 2021 20:21:54 -1000 >Subject: [PATCH] Bug 29690: Add eval on metadata record fetch in details.pl > when invalid MARCXML > >Bug 23846 added support for invalid MARCXML. >But now page details.pl fails again with software error. >This comes from several Koha::Biblio calling $self->metadata->record without eval. > >Test plan : >1) Create a biblio record with invalid MARCXML (see Bug 29690) >In koha-testing-docker there is biblionumber=369 >2) Go to page cgi-bin/koha/catalogue/detail.pl?biblionumber=xxx >3) You see the page with a message : >There is an error with this bibliographic record, the view may be degraded. >Error: Invalid data, cannot decode metadata object ... > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > Koha/Biblio.pm | 21 +++++++++++++++------ > 1 file changed, 15 insertions(+), 6 deletions(-) > >diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm >index c4c12128af..2101fe28bc 100644 >--- a/Koha/Biblio.pm >+++ b/Koha/Biblio.pm >@@ -563,15 +563,18 @@ sub get_components_query { > > my $builder = Koha::SearchEngine::QueryBuilder->new( > { index => $Koha::SearchEngine::BIBLIOS_INDEX } ); >- my $marc = $self->metadata->record; >+ >+ my $record; >+ eval { $record = $self->metadata->record }; >+ return if !$record; > > my $searchstr; > if ( C4::Context->preference('UseControlNumber') ) { >- my $pf001 = $marc->field('001') || undef; >+ my $pf001 = $record->field('001') || undef; > > if ( defined($pf001) ) { > $searchstr = "("; >- my $pf003 = $marc->field('003') || undef; >+ my $pf003 = $record->field('003') || undef; > > if ( !defined($pf003) ) { > # search for 773$w='Host001' >@@ -591,7 +594,7 @@ sub get_components_query { > } > } > else { >- my $cleaned_title = $marc->subfield('245', "a"); >+ my $cleaned_title = $record->subfield('245', "a"); > $cleaned_title =~ tr|/||; > $cleaned_title = $builder->clean_search_term($cleaned_title); > $searchstr = "Host-item:($cleaned_title)"; >@@ -650,7 +653,9 @@ Returns the COinS (a span) which can be included in a biblio record > sub get_coins { > my ( $self ) = @_; > >- my $record = $self->metadata->record; >+ my $record; >+ eval { $record = $self->metadata->record }; >+ return if !$record; > > my $pos7 = substr $record->leader(), 7, 1; > my $pos6 = substr $record->leader(), 6, 1; >@@ -940,7 +945,11 @@ sub get_marc_notes { > > my %hiddenlist = map { $_ => 1 } > split( /,/, C4::Context->preference('NotesToHide')); >- my $record = $self->metadata->record; >+ >+ my $record; >+ eval { $record = $self->metadata->record }; >+ return if !$record; >+ > $record = transformMARCXML4XSLT( $self->biblionumber, $record, $opac ); > > foreach my $field ( $record->field($scope) ) { >-- >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 29690
:
128484
|
128485
|
128486
|
128487
|
128488
|
128497
|
128530
|
128531
|
128532
|
128533
|
128541
|
128578
|
129339
|
129340
|
129341
|
129342
|
129343
|
129344
|
129345
|
129365
|
129381
|
129382
|
129542
|
129543
|
129730
|
129731