Bug 37550 - bulkmarcimport.pl dies when adding items throws an exception
Summary: bulkmarcimport.pl dies when adding items throws an exception
Status: Pushed to main
Alias: None
Product: Koha
Classification: Unclassified
Component: Command-line Utilities (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal
Assignee: Nick Clemens (kidclamp)
QA Contact: Kyle M Hall (khall)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-08-01 17:37 UTC by Nick Clemens (kidclamp)
Modified: 2024-11-07 16:33 UTC (History)
4 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
24.11.00
Circulation function:


Attachments
Bug 37550: Move item check after error handling (1.66 KB, patch)
2024-08-01 18:08 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 37550: Unit test for CheckItemPreSave (1.95 KB, patch)
2024-08-01 18:08 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 37550: CheckItemPreSave should run barcodes through barcodedecode (2.01 KB, patch)
2024-08-01 18:08 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Sample file (947 bytes, application/marc)
2024-08-23 12:41 UTC, Nick Clemens (kidclamp)
Details
Bug 37550: Move item check after error handling (1.71 KB, patch)
2024-08-23 15:38 UTC, Phil Ringnalda
Details | Diff | Splinter Review
Bug 37550: Unit test for CheckItemPreSave (2.00 KB, patch)
2024-08-23 15:38 UTC, Phil Ringnalda
Details | Diff | Splinter Review
Bug 37550: CheckItemPreSave should run barcodes through barcodedecode (2.06 KB, patch)
2024-08-23 15:38 UTC, Phil Ringnalda
Details | Diff | Splinter Review
Bug 37550: Move item check after error handling (1.76 KB, patch)
2024-11-01 12:18 UTC, Kyle M Hall (khall)
Details | Diff | Splinter Review
Bug 37550: Unit test for CheckItemPreSave (2.06 KB, patch)
2024-11-01 12:18 UTC, Kyle M Hall (khall)
Details | Diff | Splinter Review
Bug 37550: CheckItemPreSave should run barcodes through barcodedecode (2.12 KB, patch)
2024-11-01 12:18 UTC, Kyle M Hall (khall)
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Nick Clemens (kidclamp) 2024-08-01 17:37:23 UTC
The script runs item addition in an eval, and skips the record if there is an error. Before we deal with the error, however, we try to see if items were added by accessing a hash of itemnumebrs returned. When we throw an exception, the variable is not set. We should move that line after the error handling
Comment 1 Nick Clemens (kidclamp) 2024-08-01 18:08:25 UTC
Created attachment 169959 [details] [review]
Bug 37550: Move item check after error handling

To test:
1 - Grab the sample file on this bug report
2 - perl misc/migration_tools/bulkmarcimport.pl -b --file=spaceditems.pl -v
3 - An exception for 'Duplicate ID' is thrown and script dies
4 - Apply patch
5 - run script again
6 - The script finishes, no items are added, but record is
Comment 2 Nick Clemens (kidclamp) 2024-08-01 18:08:27 UTC
Created attachment 169960 [details] [review]
Bug 37550: Unit test for CheckItemPreSave
Comment 3 Nick Clemens (kidclamp) 2024-08-01 18:08:29 UTC
Created attachment 169961 [details] [review]
Bug 37550: CheckItemPreSave should run barcodes through barcodedecode

In Koha::Item we run a barcode through barcodedecode before any save.
We should do the same when checking barcodes to avoid a duplicate error
when the barcode is cleaned before it is written to the DB

To test:
1 - Follow previous test plan
2 - Note that after this patch is applied there is no exception
    All items are skipped as duplicate barcodes
Comment 4 Phil Ringnalda 2024-08-23 00:23:40 UTC
I don't see the sample file.
Comment 5 Nick Clemens (kidclamp) 2024-08-23 12:41:42 UTC
Created attachment 170630 [details]
Sample file
Comment 6 Phil Ringnalda 2024-08-23 15:38:36 UTC
Created attachment 170648 [details] [review]
Bug 37550: Move item check after error handling

To test:
1 - Grab the sample file on this bug report
2 - perl misc/migration_tools/bulkmarcimport.pl -b --file=spaceditems.pl -v
3 - An exception for 'Duplicate ID' is thrown and script dies
4 - Apply patch
5 - run script again
6 - The script finishes, no items are added, but record is

Signed-off-by: Phil Ringnalda <phil@chetcolibrary.org>
Comment 7 Phil Ringnalda 2024-08-23 15:38:39 UTC
Created attachment 170649 [details] [review]
Bug 37550: Unit test for CheckItemPreSave

Signed-off-by: Phil Ringnalda <phil@chetcolibrary.org>
Comment 8 Phil Ringnalda 2024-08-23 15:38:41 UTC
Created attachment 170650 [details] [review]
Bug 37550: CheckItemPreSave should run barcodes through barcodedecode

In Koha::Item we run a barcode through barcodedecode before any save.
We should do the same when checking barcodes to avoid a duplicate error
when the barcode is cleaned before it is written to the DB

To test:
1 - Follow previous test plan
2 - Note that after this patch is applied there is no exception
    All items are skipped as duplicate barcodes

Signed-off-by: Phil Ringnalda <phil@chetcolibrary.org>
Comment 9 Kyle M Hall (khall) 2024-11-01 12:18:43 UTC
Created attachment 173868 [details] [review]
Bug 37550: Move item check after error handling

To test:
1 - Grab the sample file on this bug report
2 - perl misc/migration_tools/bulkmarcimport.pl -b --file=spaceditems.pl -v
3 - An exception for 'Duplicate ID' is thrown and script dies
4 - Apply patch
5 - run script again
6 - The script finishes, no items are added, but record is

Signed-off-by: Phil Ringnalda <phil@chetcolibrary.org>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 10 Kyle M Hall (khall) 2024-11-01 12:18:50 UTC
Created attachment 173869 [details] [review]
Bug 37550: Unit test for CheckItemPreSave

Signed-off-by: Phil Ringnalda <phil@chetcolibrary.org>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 11 Kyle M Hall (khall) 2024-11-01 12:18:52 UTC
Created attachment 173870 [details] [review]
Bug 37550: CheckItemPreSave should run barcodes through barcodedecode

In Koha::Item we run a barcode through barcodedecode before any save.
We should do the same when checking barcodes to avoid a duplicate error
when the barcode is cleaned before it is written to the DB

To test:
1 - Follow previous test plan
2 - Note that after this patch is applied there is no exception
    All items are skipped as duplicate barcodes

Signed-off-by: Phil Ringnalda <phil@chetcolibrary.org>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 12 Katrin Fischer 2024-11-07 16:33:45 UTC
Pushed for 24.11!

Well done everyone, thank you!