From c097e91254c8b39013b474cdba6fdd6ea3d0b541 Mon Sep 17 00:00:00 2001 From: Fridolin Somers Date: Fri, 7 Aug 2020 10:05:52 +0200 Subject: [PATCH] Bug 26171: Show biblionumber in Koha::Exceptions::Metadata::Invalid Bug 23846 added a check for invalid MARCXML in search_for_data_inconsistencies.pl. But the error message does not show the biblionumber of invalid biblio record. Test plan: 1) Import a bibliographic record with invalid XML, you can add non printable characters, like 0x1F (CTRL-V 1F with vim) 2) Run misc/maintenance/search_for_data_inconsistencies.pl 3) Check you see correct biblionumber in error message : Invalid data, cannot decode object (id=xxx, biblionumber=yyy, format=marcxml, schema=zzz, decoding_error=... Signed-off-by: Victor Grousset/tuxayo Signed-off-by: Nick Clemens Signed-off-by: Jonathan Druart (cherry picked from commit 3b987412f699d16794520e1b3ec1b04b82fdd4e4) Signed-off-by: Fridolin Somers --- Koha/Biblio/Metadata.pm | 7 ++++--- Koha/Exceptions/Metadata.pm | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Koha/Biblio/Metadata.pm b/Koha/Biblio/Metadata.pm index b43a04bdb2..f55b766a4b 100644 --- a/Koha/Biblio/Metadata.pm +++ b/Koha/Biblio/Metadata.pm @@ -72,9 +72,10 @@ sub record { chomp $marcxml_error; unless ($record) { Koha::Exceptions::Metadata::Invalid->throw( - id => $self->id, - format => $self->format, - schema => $self->schema, + id => $self->id, + biblionumber => $self->biblionumber, + format => $self->format, + schema => $self->schema, decoding_error => $marcxml_error, ); } diff --git a/Koha/Exceptions/Metadata.pm b/Koha/Exceptions/Metadata.pm index be604b18d3..78dadae348 100644 --- a/Koha/Exceptions/Metadata.pm +++ b/Koha/Exceptions/Metadata.pm @@ -25,7 +25,7 @@ use Exception::Class ( 'Koha::Exceptions::Metadata::Invalid' => { isa => 'Koha::Exceptions::Metadata', description => 'Invalid data', - fields => ['id','format','schema', 'decoding_error'] + fields => ['id', 'biblionumber', 'format', 'schema', 'decoding_error'] } ); @@ -36,8 +36,8 @@ sub full_message { unless ($msg) { if ( $self->isa('Koha::Exceptions::Metadata::Invalid') ) { - $msg = sprintf( "Invalid data, cannot decode object (id=%s, format=%s, schema=%s, decoding_error='%s')", - $self->id, $self->format, $self->schema, $self->decoding_error ); + $msg = sprintf( "Invalid data, cannot decode object (id=%s, biblionumber=%s, format=%s, schema=%s, decoding_error='%s')", + $self->id, $self->biblionumber, $self->format, $self->schema, $self->decoding_error ); } } -- 2.39.5