Bug 30831

Summary: Add unit test for BatchCommitItems
Product: Koha Reporter: Nick Clemens (kidclamp) <nick>
Component: ToolsAssignee: Nick Clemens (kidclamp) <nick>
Status: CLOSED FIXED QA Contact: Martin Renvoize (ashimema) <martin.renvoize>
Severity: major    
Priority: P5 - low CC: 1joynelson, arthur.suzuki, david, jonathan.druart, lucas, martin.renvoize, tomascohen, victor
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28152
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
22.11.00, 22.05.01, 21.11.07
Circulation function:
Bug Depends on: 28152, 30830    
Bug Blocks:    
Attachments: Bug 30831: Unit test
Bug 30831: Store error in import_error column
Bug 30831: Unit test
Bug 30831: Unit test

Description Nick Clemens (kidclamp) 2022-05-23 12:23:47 UTC
In C4::ImportBatch::BatchCommitItems we attempt to store the error 'duplicate item barcode' in the 'itemnumber' column of import_items

This fails


To recreate:
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
Comment 1 Nick Clemens (kidclamp) 2022-05-23 12:24:27 UTC
Created attachment 135260 [details] [review]
Bug 30831: Unit test
Comment 2 Nick Clemens (kidclamp) 2022-05-23 12:29:10 UTC Comment hidden (obsolete)
Comment 3 Katrin Fischer 2022-05-23 12:31:02 UTC
I am pretty sure I talked about this issue on a bug with Joubu and that there was a patch, but I can't find it :(
Comment 4 Nick Clemens (kidclamp) 2022-05-23 12:49:10 UTC
(In reply to Katrin Fischer from comment #3)
> I am pretty sure I talked about this issue on a bug with Joubu and that
> there was a patch, but I can't find it :(

Bug 28152 - SO, but no unit tests, otherwise essentially the same patch
Comment 5 Nick Clemens (kidclamp) 2022-05-23 14:18:43 UTC
(In reply to Nick Clemens from comment #4)
> (In reply to Katrin Fischer from comment #3)
> > I am pretty sure I talked about this issue on a bug with Joubu and that
> > there was a patch, but I can't find it :(
> 
> Bug 28152 - SO, but no unit tests, otherwise essentially the same patch

PQA on that one,just a unit test here now
Comment 6 David Nind 2022-05-23 16:24:00 UTC
Created attachment 135280 [details] [review]
Bug 30831: Unit test

Signed-off-by: David Nind <david@davidnind.com>
Comment 7 David Nind 2022-05-23 16:27:30 UTC
Testing notes:

- Ran prove t/db_dependent/ImportBatch.t before and after applying the patch: tests passed

- After applying the patch (including dependencies) the import now works!
Comment 8 Martin Renvoize (ashimema) 2022-05-24 06:52:00 UTC
Created attachment 135297 [details] [review]
Bug 30831: Unit test

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 9 Martin Renvoize (ashimema) 2022-05-24 06:52:16 UTC
PQA
Comment 10 Tomás Cohen Arazi (tcohen) 2022-05-31 12:02:35 UTC
Pushed to master for 22.11, thanks!
Comment 11 Lucas Gass (lukeg) 2022-06-06 14:37:05 UTC
Pushed to 22.05.x for 22.05.01
Comment 12 Arthur Suzuki 2022-06-07 10:12:46 UTC
pushed to 21.11.x for 21.11.07, thx!
Comment 13 Victor Grousset/tuxayo 2022-06-25 21:46:46 UTC
Not backported to oldoldstable (21.05.x). Feel free to ask if it's needed.