Bug 30831 - Add unit test for BatchCommitItems
Summary: Add unit test for BatchCommitItems
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Tools (show other bugs)
Version: Main
Hardware: All All
: P5 - low major
Assignee: Nick Clemens (kidclamp)
QA Contact: Martin Renvoize (ashimema)
URL:
Keywords:
Depends on: 28152 30830
Blocks:
  Show dependency treegraph
 
Reported: 2022-05-23 12:23 UTC by Nick Clemens (kidclamp)
Modified: 2023-06-08 22:26 UTC (History)
8 users (show)

See Also:
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:


Attachments
Bug 30831: Unit test (2.35 KB, patch)
2022-05-23 12:24 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 30831: Store error in import_error column (4.16 KB, patch)
2022-05-23 12:29 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 30831: Unit test (2.40 KB, patch)
2022-05-23 16:24 UTC, David Nind
Details | Diff | Splinter Review
Bug 30831: Unit test (2.46 KB, patch)
2022-05-24 06:52 UTC, Martin Renvoize (ashimema)
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) 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.