Bugzilla – Attachment 152360 Details for
Bug 34014
There is no way to fix records with broken MARCXML
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 34014: Allow staff to edit degraded records
Bug-34014-Allow-staff-to-edit-degraded-records.patch (text/plain), 3.91 KB, created by
Nick Clemens (kidclamp)
on 2023-06-14 19:22:49 UTC
(
hide
)
Description:
Bug 34014: Allow staff to edit degraded records
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2023-06-14 19:22:49 UTC
Size:
3.91 KB
patch
obsolete
>From c0ace5c1b10d3a342c3274965a2b5b78c8d889e2 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Wed, 14 Jun 2023 19:05:14 +0000 >Subject: [PATCH] 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! >--- > C4/Biblio.pm | 10 +++++++++- > cataloguing/addbiblio.pl | 8 ++++++-- > .../prog/en/modules/cataloguing/addbiblio.tt | 6 ++++++ > 3 files changed, 21 insertions(+), 3 deletions(-) > >diff --git a/C4/Biblio.pm b/C4/Biblio.pm >index 2c63adb00e..50fecf0650 100644 >--- a/C4/Biblio.pm >+++ b/C4/Biblio.pm >@@ -93,6 +93,7 @@ use C4::Charset qw( > nsb_clean > SetMarcUnicodeFlag > SetUTF8Flag >+ StripNonXmlChars > ); > use C4::Languages; > use C4::Linker; >@@ -371,7 +372,14 @@ 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 $error = ""; >+ eval { $record = $biblio->metadata->record }; >+ if( $@ ){ >+ $record = MARC::Record->new_from_xml( StripNonXmlChars($biblio->metadata->metadata), 'UTF-8',$biblio->metadata->schema ); >+ $error = " | Record had encoding errors: " . $@; >+ } >+ logaction( "CATALOGUING", "MODIFY", $biblionumber, "biblio BEFORE=>" . $record->as_formatted . $error ); > } > > if ( !$options->{disable_autolink} && C4::Context->preference('AutoLinkBiblios') ) { >diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl >index 23a2fa45a3..34aa27be07 100755 >--- a/cataloguing/addbiblio.pl >+++ b/cataloguing/addbiblio.pl >@@ -43,7 +43,7 @@ use C4::Context; > use MARC::Record; > use C4::ClassSource qw( GetClassSources ); > use C4::ImportBatch qw( GetImportRecordMarc ); >-use C4::Charset qw( SetMarcUnicodeFlag ); >+use C4::Charset qw( SetMarcUnicodeFlag StripNonXmlChars ); > use Koha::BiblioFrameworks; > use Koha::DateUtils qw( dt_from_string ); > >@@ -577,7 +577,11 @@ my ( > ); > > if ( $biblio && !$breedingid ) { >- $record = $biblio->metadata->record; >+ eval { $record = $biblio->metadata->record }; >+ if( $@ ){ >+ $template->param( yucky_record => $@ ); >+ $record = MARC::Record->new_from_xml( StripNonXmlChars($biblio->metadata->metadata), 'UTF-8',$biblio->metadata->schema ); >+ } > } > if ($breedingid) { > ( $record, $encoding ) = MARCfindbreeding( $breedingid ) ; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt >index 81a9dae8ca..08b4ef23c9 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt >@@ -809,6 +809,12 @@ function PopupMARCFieldDoc(field) { > [% END #/ WRAPPER sub-header.inc %] > > <div class="main container-fluid"> >+ [% IF yucky_record %] >+ <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">[% yucky_record | html %]</span> >+ </div> >+ [% END %] > <div class="row"> > <div class="col-md-10 col-md-offset-1"> > >-- >2.30.2
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 34014
:
152360
|
157274
|
157275
|
157276
|
157277
|
157280
|
157401
|
157402
|
157403
|
157404
|
157405