Bugzilla – Attachment 162613 Details for
Bug 18138
Use MARC modification template when adding/updating bibliographic records
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18138: Display error when template missing in advanced editor
Bug-18138-Display-error-when-template-missing-in-a.patch (text/plain), 4.37 KB, created by
David Gustafsson
on 2024-02-29 18:13:54 UTC
(
hide
)
Description:
Bug 18138: Display error when template missing in advanced editor
Filename:
MIME Type:
Creator:
David Gustafsson
Created:
2024-02-29 18:13:54 UTC
Size:
4.37 KB
patch
obsolete
>From bfa7c3d18ebd9428c4a2cf359b8e06d4565b7349 Mon Sep 17 00:00:00 2001 >From: David Gustafsson <david.gustafsson@ub.gu.se> >Date: Thu, 29 Feb 2024 19:12:24 +0100 >Subject: [PATCH] Bug 18138: Display error when template missing in advanced > editor > >--- > .../intranet-tmpl/lib/koha/cateditor/koha-backend.js | 12 ++++++++++-- > .../intranet-tmpl/prog/en/includes/cateditor-ui.inc | 2 ++ > svc/bib | 9 ++++++--- > 3 files changed, 18 insertions(+), 5 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/lib/koha/cateditor/koha-backend.js b/koha-tmpl/intranet-tmpl/lib/koha/cateditor/koha-backend.js >index 5410f775633..d51e1727e99 100644 >--- a/koha-tmpl/intranet-tmpl/lib/koha/cateditor/koha-backend.js >+++ b/koha-tmpl/intranet-tmpl/lib/koha/cateditor/koha-backend.js >@@ -23,6 +23,14 @@ define( [ '/cgi-bin/koha/svc/cataloguing/framework?frameworkcode=&callback=defin > var _framework_mappings = {}; > var _framework_kohafields = {}; > >+ function _biblioSaveError( data ) { >+ var error; >+ if (data.responseXML) { >+ error = $(data.responseXML).find('error').first().text(); >+ } >+ return error || _('Could not save record'); >+ } >+ > function _fromXMLStruct( data ) { > result = {}; > >@@ -148,7 +156,7 @@ define( [ '/cgi-bin/koha/svc/cataloguing/framework?frameworkcode=&callback=defin > } > callback( record ); > } ).fail( function( data ) { >- callback( { error: _('Could not save record') } ); >+ callback( { error: _biblioSaveError( data ) } ); > } ); > }, > >@@ -169,7 +177,7 @@ define( [ '/cgi-bin/koha/svc/cataloguing/framework?frameworkcode=&callback=defin > } > callback( record ); > } ).fail( function( data ) { >- callback( { error: _('Could not save record') } ); >+ callback( { error: _biblioSaveError( data ) } ); > } ); > }, > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc >index 2ff15873b0c..7d26f52ff0d 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc >@@ -1108,6 +1108,8 @@ require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr > humanMsg.displayAlert( _("Incorrect syntax, cannot save"), { className: 'humanError' } ); > } else if ( result.error == 'invalid' ) { > humanMsg.displayAlert( _("Record structure invalid, cannot save"), { className: 'humanError' } ); >+ } else if ( result.error == 'missing_marc_modification_template' ) { >+ humanMsg.displayAlert( _("Missing marc modification template, cannot save"), { className: 'humanError' } ); > } else if ( result.error ) { > humanMsg.displayAlert( _("Something went wrong, cannot save"), { className: 'humanError' } ); > } else if ( !result.error ) { >diff --git a/svc/bib b/svc/bib >index 7d055af3ce2..62c99c1b139 100755 >--- a/svc/bib >+++ b/svc/bib >@@ -102,10 +102,11 @@ sub update_bib { > > my $result = {}; > my $inxml = $query->param('POSTDATA'); >- print $query->header(-type => 'text/xml', -charset => 'utf-8'); > > my $record = eval {MARC::Record::new_from_xml( $inxml, "UTF-8", C4::Context->preference('marcflavour'))}; > my $do_not_escape = 0; >+ >+ > if ($@) { > $result->{'status'} = "failed"; > $result->{'error'} = $@; >@@ -134,7 +135,9 @@ sub update_bib { > if ($template) { > ModifyRecordWithTemplate( $template_id, $record ); > } else { >- croak "No MARC modification template exists with id \"$template_id\""; >+ print $query->header(-type => 'text/xml', -status => '500 Internal Server Error'); >+ print XMLout({ error => 'missing_marc_modification_template' }, NoAttr => 1, RootName => 'response', XMLDecl => 1); >+ exit 0; > } > } > >@@ -149,7 +152,7 @@ sub update_bib { > $result->{'marcxml'} = $xml; > $do_not_escape = 1; > } >- >+ print $query->header(-type => 'text/xml', -charset => 'utf-8'); > print XMLout($result, NoAttr => 1, RootName => 'response', XMLDecl => 1, NoEscape => $do_not_escape); > } > >-- >2.43.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 18138
:
61442
|
61443
|
61734
|
82783
|
86617
|
110266
|
110269
|
110270
|
110272
|
118439
|
118440
|
118441
|
118442
|
118443
|
118444
|
118824
|
120709
|
123125
|
123127
|
123128
|
123129
|
123130
|
123131
|
123132
|
123133
|
123137
|
124466
|
124467
|
124468
|
124469
|
124470
|
124471
|
124472
|
124473
|
124474
|
124475
|
124476
|
124477
|
124478
|
124484
|
124485
|
124486
|
124492
|
124493
|
124991
|
125157
|
148004
|
148005
|
148006
|
148007
|
148008
|
148009
|
157183
|
157184
|
157185
|
157186
|
157187
|
157188
|
157189
|
157190
|
157485
|
157486
|
157487
|
157488
|
157489
|
157490
|
157491
|
158414
|
158415
|
158416
|
158417
|
158418
|
158419
|
158420
|
158421
|
162612
| 162613