Bugzilla – Attachment 113845 Details for
Bug 26557
Batch import fails when incoming records contain itemnumber
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 26557: (bug 23463 follow-up) Fix Batch import when incoming records contain itemnumber
Bug-26557-bug-23463-follow-up-Fix-Batch-import-whe.patch (text/plain), 3.16 KB, created by
David Nind
on 2020-11-19 18:47:53 UTC
(
hide
)
Description:
Bug 26557: (bug 23463 follow-up) Fix Batch import when incoming records contain itemnumber
Filename:
MIME Type:
Creator:
David Nind
Created:
2020-11-19 18:47:53 UTC
Size:
3.16 KB
patch
obsolete
>From 88c1f57971df0937078c73e49e62725aa769ad73 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 19 Nov 2020 15:16:36 +0100 >Subject: [PATCH] Bug 26557: (bug 23463 follow-up) Fix Batch import when > incoming records contain itemnumber > >Prior to ug 23463 AddItemFromMarc where calling AddItem, that did not >take into account the itemnumber field. >Now that we are using Koha::Item, we need to remove the items.itemnumber >field from the MARC record > >Test plan: >1 - find an existing bib in your system with just one item >2 - export that bib with the item attached >3 - delete the barcode from your item in Koha >4 - stage your exported marc file for reimport, match on biblionumber, set it to Always Add Items >5 - confirm that the bib matches and the incoming 952 is parsed >6 - click "Import this batch into the catalog" > >=> Without this patch you get (in the logs, or hidden) >manage-marc-import.pl: DBD::mysql::st execute failed: Duplicate entry '23' for key 'PRIMARY' [for Statement "INSERT INTO `items` ( `barcode`, `biblioitemnumber`, `biblionumber`, `ccode`, `cn_sort`, `cn_source`, `damaged_on`, `dateaccessioned`, `datelastborrowed`, `datelastseen`, `holdingbranch`, `homebranch`, `itemcallnumber`, `itemlost_on`, `itemnumber`, `itype`, `location`, `more_subfields_xml`, `onloan`, `permanent_location`, `replacementpricedate`, `timestamp`, `withdrawn_on`) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, current_timestamp, ? )" with ParamValues: 0="BC_23", 1=8, 2=8, 3="REF", 4='CN__23', 5=undef, 6=undef, 7="2014-09-04", 8=undef, 9="2014-09-04", 10="FPL", 11="FPL", 12="CN_23", 13=undef, 14="23", 15="BK", 16="GEN", 17=undef, 18=undef, 19="GEN", 20="2014-09-04", 21=undef] at /usr/share/perl5/DBIx/Class/Storage/DBI.pm line 1836. >manage-marc-import.pl: DBIx::Class::Storage::DBI::_dbh_execute(): Duplicate entry '23' for key 'PRIMARY' at /kohadevbox/koha/Koha/Object.pm line 169 >manage-marc-import.pl: {UNKNOWN}: Transaction aborted: Duplicate ID. Rollback failed: DBIx::Class::Storage::txn_rollback(): Refusing to roll back without a started transaction at /kohadevbox/koha/tools/manage-marc-import.pl line 253 at /kohadevbox/koha/tools/manage-marc-import.pl line 253 > >=> With this patch applied, the new item must be added to the existing bibliographic record > >Signed-off-by: David Nind <david@davidnind.com> > >Signed-off-by: David Nind <david@davidnind.com> >--- > C4/ImportBatch.pm | 4 ++++ > 1 file changed, 4 insertions(+) > >diff --git a/C4/ImportBatch.pm b/C4/ImportBatch.pm >index 6b15dbe69b..7064f94728 100644 >--- a/C4/ImportBatch.pm >+++ b/C4/ImportBatch.pm >@@ -773,6 +773,10 @@ sub BatchCommitItems { > $updsth->execute(); > $num_items_errored++; > } else { >+ # Remove the itemnumber if it exists, we want to create a new item >+ my ( $itemtag, $itemsubfield ) = GetMarcFromKohaField( "items.itemnumber" ); >+ $item_marc->field($itemtag)->delete_subfield( code => $itemsubfield ); >+ > my ( $item_biblionumber, $biblioitemnumber, $itemnumber ) = AddItemFromMarc( $item_marc, $biblionumber ); > if( $itemnumber ) { > $updsth->bind_param( 1, 'imported' ); >-- >2.11.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 26557
:
113816
|
113844
|
113845
|
113848
|
113871