Bugzilla – Attachment 55359 Details for
Bug 6852
Staged import reports wrong success for items with false branchcode
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[SIGNED-OFF] Bug 6852: Staged import reports wrong success for items
SIGNED-OFF-Bug-6852-Staged-import-reports-wrong-su.patch (text/plain), 3.14 KB, created by
Owen Leonard
on 2016-09-08 16:08:24 UTC
(
hide
)
Description:
[SIGNED-OFF] Bug 6852: Staged import reports wrong success for items
Filename:
MIME Type:
Creator:
Owen Leonard
Created:
2016-09-08 16:08:24 UTC
Size:
3.14 KB
patch
obsolete
>From 73323eed2c905c56524d643f4a9880a3076c3544 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Thu, 8 Sep 2016 12:06:05 +0200 >Subject: [PATCH] [SIGNED-OFF] Bug 6852: Staged import reports wrong success > for items >Content-Type: text/plain; charset="utf-8" > >If we import items that have a wrong branch code, the items will not >be imported but manage-marc-import reports them as imported. (A wrong >branch code probably occurs most, but other causes are possible too.) > >The underlying cause is that AddItem does not look at the error >returned from _koha_new_item in Items.pm. > >This patch deals with that omission in the most economical way. It adjusts >AddItem so that it returns undef if no item was added. >In ImportBatch.pm I check if an item was added and adjust the totals >accordingly instead of just always counting them. > >Note: Several scripts like additem.pl use AddItemFromMarc to call >AddItem. They do not report an error, but fail silently. With this patch, >these scripts get undef and will still fail silently. (No change.) >Adding error checks around calls of AddItemFromMarc is outside the scope of >this report. Here we are taking care of correct imported item numbers. > >Test plan: >[1] Verify that additem.pl still works by adding a new item. >[2] Run t/db_dependent/Items.t >[3] Add a new branchcode, say XXX. >[4] Pick a biblio record with a few items (n) and set one item to branch XXX. >[5] Export this biblio with items to a MARC file. >[6] Change the XXX item to the original branch and remove branch XXX. >[7] Import the MARC file. Verify that one item was not imported and that > the number of imported items reflects that (equals n-1). > >Signed-off-by: Owen Leonard <oleonard@myacpl.org> >--- > C4/ImportBatch.pm | 14 ++++++++------ > C4/Items.pm | 3 +++ > 2 files changed, 11 insertions(+), 6 deletions(-) > >diff --git a/C4/ImportBatch.pm b/C4/ImportBatch.pm >index 51fcb76..88d670d 100644 >--- a/C4/ImportBatch.pm >+++ b/C4/ImportBatch.pm >@@ -785,12 +785,14 @@ sub BatchCommitItems { > $num_items_errored++; > } else { > my ( $item_biblionumber, $biblioitemnumber, $itemnumber ) = AddItemFromMarc( $item_marc, $biblionumber ); >- $updsth->bind_param( 1, 'imported' ); >- $updsth->bind_param( 2, $itemnumber ); >- $updsth->bind_param( 3, $row->{'import_items_id'} ); >- $updsth->execute(); >- $updsth->finish(); >- $num_items_added++; >+ if( $itemnumber ) { >+ $updsth->bind_param( 1, 'imported' ); >+ $updsth->bind_param( 2, $itemnumber ); >+ $updsth->bind_param( 3, $row->{'import_items_id'} ); >+ $updsth->execute(); >+ $updsth->finish(); >+ $num_items_added++; >+ } > } > } > >diff --git a/C4/Items.pm b/C4/Items.pm >index dd7614c..bb23406 100644 >--- a/C4/Items.pm >+++ b/C4/Items.pm >@@ -309,6 +309,9 @@ sub AddItem { > } > > my ( $itemnumber, $error ) = _koha_new_item( $item, $item->{barcode} ); >+ if( $error ) { >+ return; >+ } > $item->{'itemnumber'} = $itemnumber; > > ModZebra( $item->{biblionumber}, "specialUpdate", "biblioserver" ); >-- >2.1.4
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 6852
:
5333
|
5334
|
55330
|
55331
|
55359
|
55477