Bugzilla – Attachment 129342 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: Always warn if something is wrong with the metadata
Bug-29690-Always-warn-if-something-is-wrong-with-t.patch (text/plain), 4.42 KB, created by
Tomás Cohen Arazi (tcohen)
on 2022-01-12 13:11:16 UTC
(
hide
)
Description:
Bug 29690: Always warn if something is wrong with the metadata
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2022-01-12 13:11:16 UTC
Size:
4.42 KB
patch
obsolete
>From 0f2c38f16a08c814751287f02fcf7ddd92325c23 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 14 Dec 2021 10:56:08 +0100 >Subject: [PATCH] Bug 29690: Always warn if something is wrong with the > metadata > >Signed-off-by: David Nind <david@davidnind.com> >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > Koha/Biblio.pm | 35 ++++++++++++++--------------------- > t/db_dependent/Koha/Biblio.t | 7 +++++-- > 2 files changed, 19 insertions(+), 23 deletions(-) > >diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm >index 7b0422e9bd..afecf22ca6 100644 >--- a/Koha/Biblio.pm >+++ b/Koha/Biblio.pm >@@ -427,9 +427,8 @@ sub host_items { > $analyticfield = '461'; > } > >- my $record; >- $record = eval { $self->metadata->record; }; >- return if !$record; >+ my $record = eval { $self->metadata->record }; >+ unless ( $record ) { warn $@ ; return } > > my @itemnumbers; > foreach my $field ( $record->field($analyticfield) ) { >@@ -568,9 +567,8 @@ sub get_components_query { > my $builder = Koha::SearchEngine::QueryBuilder->new( > { index => $Koha::SearchEngine::BIBLIOS_INDEX } ); > >- my $record; >- eval { $record = $self->metadata->record }; >- return if !$record; >+ my $record = eval { $self->metadata->record }; >+ unless ( $record ) { warn $@ ; return } > > my $searchstr; > if ( C4::Context->preference('UseControlNumber') ) { >@@ -657,9 +655,8 @@ Returns the COinS (a span) which can be included in a biblio record > sub get_coins { > my ( $self ) = @_; > >- my $record; >- eval { $record = $self->metadata->record }; >- return if !$record; >+ my $record = eval { $self->metadata->record }; >+ unless ( $record ) { warn $@ ; return } > > my $pos7 = substr $record->leader(), 7, 1; > my $pos6 = substr $record->leader(), 6, 1; >@@ -852,9 +849,8 @@ sub is_serial { > > return 1 if $self->serial; > >- my $record; >- eval { $record = $self->metadata->record }; >- return 0 if !$record; >+ my $record = eval { $self->metadata->record }; >+ unless ( $record ) { warn $@ ; return 0 } > > return 1 if substr($record->leader, 7, 1) eq 's'; > >@@ -894,9 +890,8 @@ sub custom_cover_image_url { > my $field = $+{field}; > my $subfield = $+{subfield}; > >- my $record; >- eval { $record = $self->metadata->record }; >- return "" if !$record; >+ my $record = eval { $self->metadata->record }; >+ unless ( $record ) { warn $@ ; return q{} } > > my $value; > if ( $subfield ) { >@@ -957,9 +952,8 @@ sub get_marc_notes { > my %hiddenlist = map { $_ => 1 } > split( /,/, C4::Context->preference('NotesToHide')); > >- my $record; >- eval { $record = $self->metadata->record }; >- return [] if !$record; >+ my $record = eval { $self->metadata->record }; >+ unless ( $record ) { warn $@ ; return [] } > > $record = transformMARCXML4XSLT( $self->biblionumber, $record, $opac ); > >@@ -1140,9 +1134,8 @@ sub get_marc_host { > return if C4::Context->preference('marcflavour') eq 'UNIMARC'; # TODO > return if $params->{no_items} && $self->items->count > 0; > >- my $record; >- eval { $record = $self->metadata->record }; >- return if !$record; >+ my $record = eval { $self->metadata->record }; >+ unless ( $record ) { warn $@ ; return } > > # We pick the first $w with your MARCOrgCode or the first $w that has no > # code (between parentheses) at all. >diff --git a/t/db_dependent/Koha/Biblio.t b/t/db_dependent/Koha/Biblio.t >index 8aa5bbe5d9..e828b878f6 100755 >--- a/t/db_dependent/Koha/Biblio.t >+++ b/t/db_dependent/Koha/Biblio.t >@@ -565,7 +565,7 @@ subtest 'get_marc_components() tests' => sub { > }; > > subtest 'get_components_query' => sub { >- plan tests => 4; >+ plan tests => 5; > > my $biblio = $builder->build_sample_biblio(); > my $biblionumber = $biblio->biblionumber; >@@ -592,7 +592,10 @@ subtest 'get_components_query' => sub { > $biblio->metadata->metadata('This is invalid for a MARC record')->store(); > $biblio = Koha::Biblios->find( $biblio->biblionumber); > >- is($biblio->get_components_query, undef, "Invalid MARC record returns undefined and does not die"); >+ my $components_query; >+ warning_like { $biblio->get_components_query } >+ qr{^Invalid data, cannot decode metadata object}; >+ is( $components_query, undef, "Invalid MARC record returns undefined and does not die"); > }; > > subtest 'orders() and active_orders() tests' => sub { >-- >2.32.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 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