Bugzilla – Attachment 135262 Details for
Bug 30831
Add unit test for BatchCommitItems
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30831: Store error in import_error column
Bug-30831-Store-error-in-importerror-column.patch (text/plain), 4.16 KB, created by
Nick Clemens (kidclamp)
on 2022-05-23 12:29:10 UTC
(
hide
)
Description:
Bug 30831: Store error in import_error column
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2022-05-23 12:29:10 UTC
Size:
4.16 KB
patch
obsolete
>From 4bf861136d13670d6c41a0e36afade5cba63f1a5 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Mon, 23 May 2022 12:26:42 +0000 >Subject: [PATCH] Bug 30831: Store error in import_error column > >To test: >1 - Export a record with items from the catalog >2 - Stage the record for import >3 - Import the batch >4 - Silent failure? Batch stuck in 'importing >5 - Bonus points/QA team, otherwise skip: > Stage again, go to manage batch, before clicking 'Import this batch' > a - Right click and inspect the submit button > b - Scroll to <form> element > c - Right click and 'Edit as HTML' > d - Add '?runinbackground=0' to form action > e - Delete the hidden input for 'runinbackground' a few lines down > f - Click 'Import' > g - Error: >[Mon May 23 10:47:43.583448 2022] [cgi:error] [pid 3114] [client 172.18.0.1:60936] AH01215: C4::ImportBatch::BatchCommitItems(): DBI Exception: DBD::mysql::st execute failed: Incorrect integer value: 'duplicate item barcode' for column `koha_kohadev`.`import_items`.`itemnumber` at row 1 at /kohadevbox/koha/C4/ImportBatch.pm line 652: /kohadevbox/koha/tools/manage-marc-import.pl, referer: http://localhost:8081/cgi-bin/koha/tools/manage-marc-import.pl?import_batch_id=2 >6 - Apply patch >7 - Stage and import record again >8 - Import success! >9 - Note results report 'Number of items ignored because of duplicate barcode' equal to number of items on record >--- > C4/ImportBatch.pm | 16 ++++++++++------ > 1 file changed, 10 insertions(+), 6 deletions(-) > >diff --git a/C4/ImportBatch.pm b/C4/ImportBatch.pm >index e0dd051491..956c957ebf 100644 >--- a/C4/ImportBatch.pm >+++ b/C4/ImportBatch.pm >@@ -770,13 +770,14 @@ sub BatchCommitItems { > my $duplicate_barcode = exists( $item->{'barcode'} ) && Koha::Items->find({ barcode => $item->{'barcode'} }); > my $duplicate_itemnumber = exists( $item->{'itemnumber'} ); > >- my $updsth = $dbh->prepare("UPDATE import_items SET status = ?, itemnumber = ? WHERE import_items_id = ?"); >+ my $updsth = $dbh->prepare("UPDATE import_items SET status = ?, itemnumber = ?, import_error = ? WHERE import_items_id = ?"); > if ( $action eq "replace" && $duplicate_itemnumber ) { > # Duplicate itemnumbers have precedence, that way we can update barcodes by overlaying > ModItemFromMarc( $item_marc, $biblionumber, $item->{itemnumber} ); > $updsth->bind_param( 1, 'imported' ); > $updsth->bind_param( 2, $item->{itemnumber} ); >- $updsth->bind_param( 3, $row->{'import_items_id'} ); >+ $updsth->bind_param( 3, undef ); >+ $updsth->bind_param( 4, $row->{'import_items_id'} ); > $updsth->execute(); > $updsth->finish(); > $num_items_replaced++; >@@ -785,14 +786,16 @@ sub BatchCommitItems { > ModItemFromMarc( $item_marc, $biblionumber, $itemnumber ); > $updsth->bind_param( 1, 'imported' ); > $updsth->bind_param( 2, $item->{itemnumber} ); >- $updsth->bind_param( 3, $row->{'import_items_id'} ); >+ $updsth->bind_param( 3, undef ); >+ $updsth->bind_param( 4, $row->{'import_items_id'} ); > $updsth->execute(); > $updsth->finish(); > $num_items_replaced++; > } elsif ($duplicate_barcode) { > $updsth->bind_param( 1, 'error' ); >- $updsth->bind_param( 2, 'duplicate item barcode' ); >- $updsth->bind_param( 3, $row->{'import_items_id'} ); >+ $updsth->bind_param( 2, undef ); >+ $updsth->bind_param( 3, 'duplicate item barcode' ); >+ $updsth->bind_param( 4, $row->{'import_items_id'} ); > $updsth->execute(); > $num_items_errored++; > } else { >@@ -804,7 +807,8 @@ sub BatchCommitItems { > if( $itemnumber ) { > $updsth->bind_param( 1, 'imported' ); > $updsth->bind_param( 2, $itemnumber ); >- $updsth->bind_param( 3, $row->{'import_items_id'} ); >+ $updsth->bind_param( 3, undef ); >+ $updsth->bind_param( 4, $row->{'import_items_id'} ); > $updsth->execute(); > $updsth->finish(); > $num_items_added++; >-- >2.30.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 30831
:
135260
|
135262
|
135280
|
135297