Bug 34014: Allow staff to edit degraded records

This patch adds an eval to the call for the record form metadata

If there is an error we catch it, display it, and attempt to strip bad characters from the record

To test:
1 - In koha testing docker attempt to view record 369 in the staff interface
2 - You see a warning about degraded view
3 - Attempt to edit the record
4 - Internal server error
5 - Apply patch, restart all
6 - Reload the editor
7 - Record successfully loads!
8 - You have a warning about encoding issues!
9 - Save the record
10 - No more warning!
11 - Edit again, no more warning!

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Signed-off-by: Kelly McElligott <kelly@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit 66d519ae41)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
Nick Clemens 2023-06-14 19:05:14 +00:00 committed by Fridolin Somers
parent 8c0ee5ce0d
commit c7a35b210e
3 changed files with 23 additions and 2 deletions

View file

@ -371,7 +371,16 @@ sub ModBiblio {
if ( C4::Context->preference("CataloguingLog") ) {
my $biblio = Koha::Biblios->find($biblionumber);
logaction( "CATALOGUING", "MODIFY", $biblionumber, "biblio BEFORE=>" . $biblio->metadata->record->as_formatted );
my $record;
my $decoding_error = "";
eval { $record = $biblio->metadata->record };
if( $@ ){
my $exception = $@;
$exception->rethrow unless ( $exception->isa('Koha::Exceptions::Metadata::Invalid') );
$decoding_error = "There was an error with this bibliographic record: " . $exception;
$record = $biblio->metadata->record_strip_nonxml;
}
logaction( "CATALOGUING", "MODIFY", $biblionumber, "biblio $decoding_error BEFORE=>" . $record->as_formatted );
}
if ( !$options->{disable_autolink} && C4::Context->preference('AutoLinkBiblios') ) {

View file

@ -577,7 +577,13 @@ my (
);
if ( $biblio && !$breedingid ) {
$record = $biblio->metadata->record;
eval { $record = $biblio->metadata->record };
if( $@ ){
my $exception = $@;
$exception->rethrow unless ( $exception->isa('Koha::Exceptions::Metadata::Invalid') );
$record = $biblio->metadata->record_strip_nonxml;
$template->param( INVALID_METADATA => $exception );
}
}
if ($breedingid) {
( $record, $encoding ) = MARCfindbreeding( $breedingid ) ;

View file

@ -825,6 +825,12 @@ $(document).ready(function(){
[% END #/ WRAPPER sub-header.inc %]
<div class="main container-fluid">
[% IF ( INVALID_METADATA ) %]
<div class="dialog alert">
<p>This record had encoding issues, non-xml characters have been stripped in order to allow editing. Please be cautious when saving that some data may have been removed from the record.</br>Decoding error:</p>
<span class="problem">[% INVALID_METADATA | html %]</span>
</div>
[% END %]
<div class="row">
<div class="col-md-10 col-md-offset-1">