Bug 20462

Summary: Duplicate barcodes in batch item deletion cause software error if deleting biblio records
Product: Koha Reporter: Barton Chittenden <barton>
Component: ToolsAssignee: Jonathan Druart <jonathan.druart>
Status: CLOSED FIXED QA Contact: Josef Moravec <josef.moravec>
Severity: normal    
Priority: P5 - low CC: fridolin.somers, jonathan.druart, josef.moravec, katrin.fischer, nick
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9509
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Attachments: Bug 20462: Ensure batch item deletion will not delete the same item twice
Bug 20462: Ensure batch item deletion will not delete the same item twice
Bug 20462: Ensure batch item deletion will not delete the same item twice

Description Barton Chittenden 2018-03-22 16:19:49 UTC
To re-create:

1) Create a text file containing duplicate barcodes

Here's a quick way to do that, substitute INSTANCE for the instance name of your test server:

sudo koha-mysql INSTANCE <<< "select barcode from items where barcode is not null limit 3" | sed '1d;p' > /tmp/dup_barcodes.txt

2) Go to Home › Tools › Batch item deletion
3) Click 'Choose File', select the file you created in step 1.
4) Click 'Continue'
5) Note that duplicate items appear in the list of items to batch delete
6) Check 'Delete records if no items remain'
7) This will trigger a software error

Here is the output from the intranet error log:

[Thu Mar 22 08:49:35.030497 2018] [cgi:error] [pid 26116] [client x.x.x.x:y] AH01215: [Thu Mar 22 08:49:35 2018] batchMod.pl: CCL parsing error (10014) Search word expected ZOOM for query: hi= at /usr/share/koha/lib/C4/Search.pm line 275., referer: https://intranet.bywatersolutions.com/cgi-bin/koha/tools/batchMod.pl
[Thu Mar 22 08:49:35.039872 2018] [cgi:error] [pid 26116] [client x.x.x.x:y] AH01215: [Thu Mar 22 08:49:35 2018] batchMod.pl: DBIx::Class::Storage::DBI::select_single(): Query returned more than one row.  SQL that returns multiple rows is DEPRECATED for ->find and ->single at /usr/share/koha/lib/Koha/Objects.pm line 92, referer: https://intranet.bywatersolutions.com/cgibin/koha/tools/batchMod.pl
[Thu Mar 22 08:49:35.040735 2018] [cgi:error] [pid 26116] [client x.x.x.x:y] AH01215: [Thu Mar 22 08:49:35 2018] batchMod.pl: Can't call method "items" on an undefined value at /usr/share/koha/intranet/cgi-bin/tools/batchMod.pl line 187., referer: https://intranet.bywatersolutions.com/cgi-bin/koha/tools/batchMod.pl

Note that entering the barcodes via the 'scan items one by one' text box removes duplicates in the list, so this only causes problems when uploading a file.

It doesn't matter whether you choose duplicate barcodes or duplicate item numbers, both trigger the some error.
Comment 1 Jonathan Druart 2018-03-26 15:25:54 UTC
Created attachment 73285 [details] [review]
Bug 20462: Ensure batch item deletion will not delete the same item twice

This has been done on bug 9509 when barcodes are scaned, but not when using a text file.

Test plan (stolen from Barton on the bug report):
1) Create a text file containing duplicate barcodes

Here's a quick way to do that, substitute INSTANCE for the instance name of your test server:

sudo koha-mysql INSTANCE <<< "select barcode from items where barcode is not null limit 3" | sed '1d;p' > /tmp/dup_barcodes.txt

2) Go to Home › Tools › Batch item deletion
3) Click 'Choose File', select the file you created in step 1.
4) Click 'Continue'
5) Note that duplicate items appear in the list of items to batch delete
6) Check 'Delete records if no items remain'
7) This will trigger a software error

Note that entering the barcodes via the 'scan items one by one' text box removes duplicates in the list, so this only causes problems when uploading a file.
Comment 2 Mark Tompsett 2018-03-26 23:09:29 UTC
Created attachment 73297 [details] [review]
Bug 20462: Ensure batch item deletion will not delete the same item twice

This has been done on bug 9509 when barcodes are scaned, but not when using a text file.

Test plan (stolen from Barton on the bug report):
1) Create a text file containing duplicate barcodes

Here's a quick way to do that, substitute INSTANCE for the instance name of your test server:

sudo koha-mysql INSTANCE <<< "select barcode from items where barcode is not null limit 3" | sed '1d;p' > /tmp/dup_barcodes.txt

2) Go to Home › Tools › Batch item deletion
3) Click 'Choose File', select the file you created in step 1.
4) Click 'Continue'
5) Note that duplicate items appear in the list of items to batch delete
6) Check 'Delete records if no items remain'
7) This will trigger a software error

Note that entering the barcodes via the 'scan items one by one' text box removes duplicates in the list, so this only causes problems when uploading a file.

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>
Comment 3 Josef Moravec 2018-03-29 10:11:54 UTC
Created attachment 73411 [details] [review]
Bug 20462: Ensure batch item deletion will not delete the same item twice

This has been done on bug 9509 when barcodes are scaned, but not when using a text file.

Test plan (stolen from Barton on the bug report):
1) Create a text file containing duplicate barcodes

Here's a quick way to do that, substitute INSTANCE for the instance name of your test server:

sudo koha-mysql INSTANCE <<< "select barcode from items where barcode is not null limit 3" | sed '1d;p' > /tmp/dup_barcodes.txt

2) Go to Home › Tools › Batch item deletion
3) Click 'Choose File', select the file you created in step 1.
4) Click 'Continue'
5) Note that duplicate items appear in the list of items to batch delete
6) Check 'Delete records if no items remain'
7) This will trigger a software error

Note that entering the barcodes via the 'scan items one by one' text box removes duplicates in the list, so this only causes problems when uploading a file.

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Comment 4 Jonathan Druart 2018-04-02 21:15:36 UTC
Pushed to master for 18.05, thanks to everybody involved!
Comment 5 Nick Clemens (kidclamp) 2018-05-14 21:23:09 UTC
Pushed to stable for 17.11.06

Awesome work all!
Comment 6 Fridolin Somers 2018-05-22 09:57:37 UTC
Pushed to 17.05.x for v17.05.12