Bugzilla – Attachment 131181 Details for
Bug 29440
Refactor/clean up bulkmarcimport.pl
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29440: Make authorities import behavior consistent with biblios
Bug-29440-Make-authorities-import-behavior-consist.patch (text/plain), 7.95 KB, created by
David Gustafsson
on 2022-03-01 14:52:11 UTC
(
hide
)
Description:
Bug 29440: Make authorities import behavior consistent with biblios
Filename:
MIME Type:
Creator:
David Gustafsson
Created:
2022-03-01 14:52:11 UTC
Size:
7.95 KB
patch
obsolete
>From eee1b7e701eca0890ce8f9036b5de060b7e59fa0 Mon Sep 17 00:00:00 2001 >From: David Gustafsson <glasklas@gmail.com> >Date: Tue, 9 Nov 2021 12:52:03 +0100 >Subject: [PATCH] Bug 29440: Make authorities import behavior consistent with > biblios > >The current behavior for when importing authorities, when match >option is enabled, is to insert as a new authority fetching from db >fails. This is both a bit confusing and not consistent with the biblio >case where an error is generated. Also clean up error and log messages >so both messages/errors and when messages/errors are issued are more >consistent for the biblio and authority case. > >Signed-off-by: Frank Hansen <frank.hansen@ub.lu.se> > >The patch works fine for me. >Signing off. >--- > misc/migration_tools/bulkmarcimport.pl | 62 ++++++++++++++++---------- > 1 file changed, 39 insertions(+), 23 deletions(-) > >diff --git a/misc/migration_tools/bulkmarcimport.pl b/misc/migration_tools/bulkmarcimport.pl >index 7b22124ac7..627720cee4 100755 >--- a/misc/migration_tools/bulkmarcimport.pl >+++ b/misc/migration_tools/bulkmarcimport.pl >@@ -444,30 +444,45 @@ RECORD: foreach my $record (@{$marc_records}) { > unless ($test_parameter) { > if ($authorities) { > my $authtypecode = GuessAuthTypeCode($record, $heading_fields); >- my $authid = ($matched_record_id? $matched_record_id : GuessAuthId($record)); >- if ($authid && GetAuthority($authid) && $update) { >- ## Authority has an id and is in database : Replace >- eval { ( $authid ) = ModAuthority($authid, $record, $authtypecode) }; >- if ($@) { >- warn "Problem with authority $authid Cannot Modify"; >- printlog({ id => $authid, op => "edit", status => "ERROR" }) if ($logfile); >+ my $authid; >+ >+ if ($matched_record_id) { >+ if ($update) { >+ ## Authority has an id and is in database: update >+ eval { ($authid) = ModAuthority($matched_record_id, $record, $authtypecode) }; >+ if ($@) { >+ warn "ERROR: Update authority $matched_record_id failed: $@\n"; >+ printlog({ id => $matched_record_id, op => "update", status => "ERROR" }) if ($logfile); >+ } >+ else { >+ printlog({ id => $authid, op => "update", status => "ok" }) if ($logfile); >+ } > } >- else{ >- printlog({ id=> $authid, op=> "edit", status => "ok"}) if ($logfile); >+ elsif ($logfile) { >+ warn "WARNING: Update authority $originalid skipped"; >+ printlog({ >+ id => $matched_record_id, >+ op => "update", >+ status => "warning: authority already in database and option -update not enabled, skipping..." >+ }); > } > } >- else { >- ## True insert in database >- eval { ( $authid ) = AddAuthority($record, "", $authtypecode) }; >+ elsif ($insert) { >+ ## An authid is defined but no authority in database: insert >+ eval { ($authid) = AddAuthority($record, undef, $authtypecode) }; > if ($@) { >- warn "Problem with authority $originalid Cannot Add ".$@; >+ warn "ERROR: Insert authority $originalid failed: $@\n"; > printlog({ id => $originalid, op => "insert", status => "ERROR" }) if ($logfile); > } > else { > printlog({ id => $authid, op => "insert", status => "ok" }) if ($logfile); > } >- > } >+ else { >+ warn "WARNING: Insert authority $originalid skipped"; >+ printlog( { id => $originalid, op => "insert", status => "warning : biblio not in database and option -insert not enabled, skipping..." } ) if ($logfile); >+ } >+ > if ($yamlfile) { > $yamlhash->{$originalid} = YAMLFileEntry( > $record, >@@ -497,9 +512,8 @@ RECORD: foreach my $record (@{$marc_records}) { > } > } > >- # create biblio, unless we already have it ( either match or isbn ) >+ # Create biblio, unless we already have it (either match or ISBN) > if ($matched_record_id) { >- # TODO: Implement also for authority records! > eval{ > $biblioitemnumber = Koha::Biblios->find( $matched_record_id )->biblioitem->biblioitemnumber; > }; >@@ -507,12 +521,12 @@ RECORD: foreach my $record (@{$marc_records}) { > my $success; > eval { $success = ModBiblio($record, $matched_record_id, GetFrameworkCode($matched_record_id), $modify_biblio_marc_options) }; > if ($@) { >- warn "ERROR: Edit biblio $matched_record_id failed: $@\n"; >+ warn "ERROR: Update biblio $matched_record_id failed: $@\n"; > printlog( { id => $matched_record_id, op => "update", status => "ERROR" } ) if ($logfile); > next RECORD; > } > elsif (!$success) { >- warn "ERROR: Edit biblio $matched_record_id failed for unkown reason"; >+ warn "ERROR: Update biblio $matched_record_id failed for unkown reason"; > printlog( { id => $matched_record_id, op => "update", status => "ERROR" } ) if ($logfile); > next RECORD; > } >@@ -522,23 +536,24 @@ RECORD: foreach my $record (@{$marc_records}) { > } > } > else { >+ warn "WARNING: Update biblio $originalid skipped"; > printlog( { id => $matched_record_id, op => "update", status => "warning : already in database and option -update not enabled, skipping..." } ) if ($logfile); > } > } > elsif ($insert) { > eval { ($record_id, $biblioitemnumber) = AddBiblio($record, $framework, { defer_marc_save => 1 }) }; > if ($@) { >- warn "ERROR: Adding biblio $record_id failed: $@\n"; >- printlog( { id => $record_id, op => "insert", status => "ERROR" } ) if ($logfile); >+ warn "ERROR: Insert biblio $originalid failed: $@\n"; >+ printlog( { id => $originalid, op => "insert", status => "ERROR" } ) if ($logfile); > next RECORD; > } > else { >- printlog( { id => $record_id, op => "insert", status => "ok" } ) if ($logfile); >+ printlog( { id => $originalid, op => "insert", status => "ok" } ) if ($logfile); > } > } > else { >- warn "WARNING: Updating record ".($originalid)." failed"; >- printlog( { id => $originalid, op => "insert", status => "warning : not in database and option -insert not enabled, skipping..." } ) if ($logfile); >+ warn "WARNING: Insert biblio $originalid skipped"; >+ printlog( { id => $originalid, op => "insert", status => "warning : biblio not in database and option -insert not enabled, skipping..." } ) if ($logfile); > next RECORD; > } > my $record_has_added_items = 0; >@@ -546,6 +561,7 @@ RECORD: foreach my $record (@{$marc_records}) { > $yamlhash->{$originalid} = $record_id if $yamlfile; > eval { ($itemnumbers_ref, $errors_ref) = AddItemBatchFromMarc($record, $record_id, $biblioitemnumber, $framework); }; > $record_has_added_items = @{$itemnumbers_ref}; >+ > my $error_adding = $@; > # Work on a clone so that if there are real errors, we can maybe > # fix them up later. >-- >2.34.1
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 29440
:
127479
|
127480
|
127481
|
127485
|
127486
|
127508
|
127509
|
127651
|
127652
|
127791
|
127792
|
127795
|
127796
|
127959
|
127960
|
127961
|
127963
|
128086
|
128087
|
128362
|
128890
|
128891
|
131176
|
131177
|
131180
|
131181
|
132942
|
140822
|
140823
|
140903
|
140904
|
140905
|
140906
|
140924
|
140925
|
140926
|
140927
|
140928
|
140987
|
140988
|
140989
|
143375
|
151293
|
151294
|
151295
|
151296
|
151297
|
151298
|
151299
|
151300
|
151301
|
157798
|
160148
|
160149
|
160150
|
160151
|
160152
|
160153
|
160154
|
160155
|
160156
|
160157
|
160477
|
160478
|
160479
|
160480
|
160481
|
160482
|
160483
|
160484
|
160485
|
160486
|
160487