When creating a new item, it is not allowed to add trailing spaces, it shows 'Barcode must be unique'. But it is allowed to use leading spaces :( In this case since circulation does a trim on barcode this item can not be checked-out. It also allows duplicates even with UNIQUE KEY constraint.
Hi Frido, do you plan to provide a patch?
(In reply to Jonathan Druart from comment #1) > Hi Frido, do you plan to provide a patch? I'm not sure when I can find time, feel free to propose patches.
Created attachment 126266 [details] [review] Bug 22204: Remove whitespaces in barcode before saving Test plan: 1. Create an item with barcode "1" 2. Try to create an item with barcode " 1 " and verify that it is blocked 3. Create an item with barcode " XXXXX " and verify that it is saved without spaces in database: SELECT barcode FROM items WHERE barcode LIKE '%XXXXX%' Co-authored-by: Jérémy Breuillard <jeremy.breuillard@biblibre.com>
Please have a look at: C4/Circulation.pm: barcodedecode
Please enter assignee too :)
BTW : should the trim be in Koha::Items->store() ?
Created attachment 126344 [details] [review] Bug 22204: use barcodedecode from C4/Circulation in additem.pl
194 $item->barcode(barcodedecode($item->barcode)); Is this patch really needed? Did you try itemBarcodeInputFilter=whitespace?
(In reply to Jonathan Druart from comment #8) > 194 $item->barcode(barcodedecode($item->barcode)); > > Is this patch really needed? > > Did you try itemBarcodeInputFilter=whitespace? It looks like we worked on an out-of-date master branch... (this line was added 10 days ago). We must try to reproduce the bug on master (bug 26351)
(In reply to Julian Maurice from comment #9) > (In reply to Jonathan Druart from comment #8) > > 194 $item->barcode(barcodedecode($item->barcode)); > > > > Is this patch really needed? > > > > Did you try itemBarcodeInputFilter=whitespace? > > It looks like we worked on an out-of-date master branch... (this line was > added 10 days ago). > > We must try to reproduce the bug on master (bug 26351) "(bug 26351)" was added on the wrong line. It's the bug that was pushed 10 days ago. Why can't we edit comments ?? :)
Bug tested on master branch. It works correctly.
Problem still exists in 21.05 and lower versions. The attached patches should work correctly on those versions. I will squash them for an easier review
Created attachment 126430 [details] [review] [21.05] Bug 22204: Use barcodedecode in additem.pl Test plan: 1. Set syspref itemBarcodeInputFilter to 'whitespace' 2. Create an item with barcode "1" 3. Try to create an item with barcode " 1 " and verify that it is blocked 4. Create an item with barcode " XXXXX " and verify that it is saved without spaces in database: SELECT barcode FROM items WHERE barcode LIKE '%XXXXX%' Co-authored-by: Jérémy Breuillard <jeremy.breuillard@biblibre.com>
Patch no longer applies 8-(... (using koha-testing-docker and 21.05): 126430 - [21.05] Bug 22204: Use barcodedecode in additem.pl Apply? [(y)es, (n)o, (i)nteractive] y Applying: Bug 22204: Use barcodedecode in additem.pl Using index info to reconstruct a base tree... M cataloguing/additem.pl Falling back to patching base and 3-way merge... Auto-merging cataloguing/additem.pl CONFLICT (content): Merge conflict in cataloguing/additem.pl error: Failed to merge in the changes. Patch failed at 0001 Bug 22204: Use barcodedecode in additem.pl
*** This bug has been marked as a duplicate of bug 30409 ***