Bug 20462 - Duplicate barcodes in batch item deletion cause software error if deleting biblio records
Summary: Duplicate barcodes in batch item deletion cause software error if deleting bi...
Status: Pushed to Stable
Alias: None
Product: Koha
Classification: Unclassified
Component: Tools (show other bugs)
Version: master
Hardware: All All
: P5 - low normal (vote)
Assignee: Jonathan Druart
QA Contact: Josef Moravec
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-03-22 16:19 UTC by Barton Chittenden
Modified: 2018-05-22 09:57 UTC (History)
5 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Bot Control: ---
When did the bot last check this:
Who signed the patch off:
Text to go in the release notes:


Attachments
Bug 20462: Ensure batch item deletion will not delete the same item twice (1.63 KB, patch)
2018-03-26 15:25 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 20462: Ensure batch item deletion will not delete the same item twice (1.68 KB, patch)
2018-03-26 23:09 UTC, M. Tompsett
Details | Diff | Splinter Review
Bug 20462: Ensure batch item deletion will not delete the same item twice (1.73 KB, patch)
2018-03-29 10:11 UTC, Josef Moravec
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
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 M. 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 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