Bugzilla – Attachment 189827 Details for
Bug 29654
Add option to bulkmarimport.pl for matching on original id
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29654: Add match_record_id option to bulkmarimport.pl
Bug-29654-Add-matchrecordid-option-to-bulkmarimpor.patch (text/plain), 3.26 KB, created by
David Gustafsson
on 2025-11-21 08:14:32 UTC
(
hide
)
Description:
Bug 29654: Add match_record_id option to bulkmarimport.pl
Filename:
MIME Type:
Creator:
David Gustafsson
Created:
2025-11-21 08:14:32 UTC
Size:
3.26 KB
patch
obsolete
>From a965459cd8120523df35d8ce9c8a748cf03ee6b7 Mon Sep 17 00:00:00 2001 >From: David Gustafsson <david.gustafsson@ub.gu.se> >Date: Tue, 18 Feb 2025 10:51:25 +0100 >Subject: [PATCH] Bug 29654: Add match_record_id option to bulkmarimport.pl > >Add -match_record_id option to bulkmarkimport.pl. When enabled >incoming record id will be assumed to match record in Koha. > >To test: > >1) Before applying patch, export a biblio from staff interace >2) Import using the exported file: > ./bulkmarcimport.pl -m="MARCXML" -v -b -file bib-xxxxx.marcxml -insert -update -c=MARC21 -l "/tmp/import.log" >3) The import with be inserted and create a duplicate record in Koha. > Check the import.log or search using the staff interface. > (could also crash with duplicate key error if contains item) >4) Apply patch >5) Run the import again with the same command as above >6) A new record should been inserted >7) Remove all newly inserted duplicate records (it's important to keep > the record the export was initially performed on) >6) Run the import again, but add the -match_record_id option >8) The original Koha record should now have been updated > >Sponsored-by: Gothenburg University Library >Signed-off-by: David Nind <david@davidnind.com> >--- > misc/migration_tools/bulkmarcimport.pl | 14 +++++++++++++- > 1 file changed, 13 insertions(+), 1 deletion(-) > >diff --git a/misc/migration_tools/bulkmarcimport.pl b/misc/migration_tools/bulkmarcimport.pl >index cd5fa255a6e..4c0c8c41bb7 100755 >--- a/misc/migration_tools/bulkmarcimport.pl >+++ b/misc/migration_tools/bulkmarcimport.pl >@@ -59,6 +59,7 @@ my $biblios; > my $authorities; > my $keepids; > my $match; >+my $match_record_id; > my $isbn_check; > my $logfile; > my $insert; >@@ -104,6 +105,7 @@ GetOptions( > 'update' => \$update, > 'all' => \$all, > 'match=s@' => \$match, >+ 'match_record_id' => \$match_record_id, > 'i|isbn' => \$isbn_check, > 'x:s' => \$sourcetag, > 'y:s' => \$sourcesubfield, >@@ -445,7 +447,7 @@ RECORD: while () { > $logger->debug("No match for: $query"); > } > >- if ( $keepids && $originalid ) { >+ if ( $keepids && $originalid && $originalid != $matched_record_id ) { > my $storeidfield; > if ( length($keepids) == 3 ) { > $storeidfield = MARC::Field->new( $keepids, $originalid ); >@@ -458,6 +460,10 @@ RECORD: while () { > } > } > >+ if ( $match_record_id && !$matched_record_id && $originalid ) { >+ $matched_record_id = $originalid; >+ } >+ > foreach my $stringfilter (@$filters) { > if ( length($stringfilter) == 3 ) { > foreach my $field ( $record->field($stringfilter) ) { >@@ -992,6 +998,12 @@ from LOC or BNF. useless for biblios probably) > I<FIELD> matchindex,fieldtomatch matchpoint to use to deduplicate fieldtomatch > can be either 001 to 999 or field and list of subfields as such 100abcde > >+=item B<-match_record_id> >+ >+Assume incoming record original id is a valid record id in Koha and use this >+for updating the Koha record. For example useful when importing previously >++exported records. >+ > =item B<-i, --isbn> > > If set, a search will be done on isbn, and, if the same isbn is found, the >-- >2.51.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 29654
:
128335
|
128365
|
128575
|
178169
|
182239
| 189827