Bug 23846: Display degraded view when MARCXML is invalid (staff detail)

When an invalid bibliographic record is imported into the catalogue
there is not warning or error. However the bibliographic record detail
page will explode (Koha::Biblio::Metadata->record will raise an
exception).

This patch proposes to catch the exception on this view and display a
warning about the situation.
Note that editing/saving the record will fix the MARCXML data and so
removes the warning (some black magic we should get rid of I suspect).

Test plan:
- Import a bibliographic record with invalid XML, you can add non
printable characters, like 0x1F (CTRL-V 1F with vim)
- Go to the detail page
=> Without this patch you get a 500
=> With this patch applied you get a "degraded view" with a warning
message, telling you what the error is.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Jonathan Druart 2019-11-12 11:04:42 +01:00 committed by Martin Renvoize
parent 150361c0e5
commit 068943f18d
No known key found for this signature in database
GPG Key ID: 422B469130441A0F
2 changed files with 14 additions and 1 deletions

View File

@ -112,6 +112,9 @@ if ( not defined $record ) {
exit;
}
eval { $biblio->metadata->record };
$template->param( decoding_error => $@ );
if($query->cookie("holdfor")){
my $holdfor_patron = Koha::Patrons->find( $query->cookie("holdfor") );
$template->param(
@ -143,7 +146,11 @@ if ( $xslfile ) {
}
$template->param( 'SpineLabelShowPrintOnBibDetails' => C4::Context->preference("SpineLabelShowPrintOnBibDetails") );
$template->param( ocoins => $biblio->get_coins );
# Catch the exception as Koha::Biblio::Metadata->record can explode if the MARCXML is invalid
# Do not propagate it as we already deal with it previously in this script
my $coins = eval { $biblio->get_coins };
$template->param( ocoins => $coins );
# some useful variables for enhanced content;
# in each case, we're grabbing the first value we find in

View File

@ -68,6 +68,12 @@
[% CoceHost = Koha.Preference('CoceHost') %]
[% INCLUDE 'cat-toolbar.inc' %]
[% IF decoding_error %]
<div>
There is an error with this bibliographic record, the view may be degraded.
<br/> Error: [% decoding_error %]
</div>
[% END %]
[% IF ( ocoins ) %]
<!-- COinS / OpenURL -->
<span class="Z3988" title="[% ocoins | html %]"></span>