Bug 10483

Summary: check_uniqueness.pl does not work
Product: Koha Reporter: Fridolin Somers <fridolin.somers>
Component: AcquisitionsAssignee: Fridolin Somers <fridolin.somers>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P5 - low CC: bgkriegel, chris, chrish, gmcharlt, katrin.fischer, tomascohen
Version: master   
Hardware: All   
OS: All   
See Also: http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=7178
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=8684
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Attachments: Proposed patch
Bug 10483 - check_uniqueness.pl does not work
Bug 10483 - check_uniqueness.pl does not work

Description Fridolin Somers 2013-06-17 14:54:22 UTC
When syspref "UniqueItemFields" is defined, the item uniqueness is tested in acquisition by an Ajax call to check_uniqueness.pl.
I noticed that it does not work, item is always created without alert even on existing barcode.

I have looked in perl debug mode and found that in check_uniqueness.pl :
    my $input = new CGI;
    my @field = $input->param('field');
    my @value = $input->param('value');
@field and @value are always empty.
It is because in CGI the params are named "field[]" and "value[]".
It seems to be because of the ajax serialization of a Javascript Array.
Comment 1 Fridolin Somers 2013-06-17 15:11:57 UTC Comment hidden (obsolete)
Comment 2 Katrin Fischer 2013-06-18 06:18:21 UTC
I think we have a lot of bug reports in that area that might be linked to this bug. A search for "uniqueitemfields" brings up quite a few, I think especially 8694 could maybe be fixed by this (hopefully). At least worth checking when testing this :)
Comment 3 Kyle M Hall 2013-06-21 13:07:39 UTC Comment hidden (obsolete)
Comment 4 Chris Cormack 2013-06-29 07:00:51 UTC
Created attachment 19282 [details] [review]
Bug 10483 - check_uniqueness.pl does not work

When syspref "UniqueItemFields" is defined, the item uniqueness is tested in acquisition by an Ajax call to check_uniqueness.pl.
I noticed that it does not work, item is always created without alert even on existing barcode.

I have looked in perl debug mode and found that in check_uniqueness.pl :
    my $input = new CGI;
    my @field = $input->param('field');
    my @value = $input->param('value');
@field and @value are always empty.
It is because in CGI the params are named "field[]" and "value[]".
It seems to be because of the ajax serialization of a Javascript Array.
This patch corrects this bug.

Test plan :
- Select an existing item with barcode
- Add "barcode" to "UniqueItemFields" syspref (use space as separator for multiple values)
- Set "AcqCreateItem" syspref to "Create an item when placing an order"
- Go to an acquisition basket
- Create a new order from empty
- Enter existing barcode in item form and save
=> You get an alert that barcode already exists and order is not saved
- Enter a non-existing barcode in item form and save
=> Order and item are created

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Comment 5 Galen Charlton 2013-08-14 21:19:46 UTC
Pushed to master.  Thanks, Fridolyn!
Comment 6 Tomás Cohen Arazi 2013-09-10 19:27:21 UTC
This patch has been pushed to 3.12.x, will be in 3.12.5.

Thanks Fridolyn!
Comment 7 Bernardo Gonzalez Kriegel 2013-09-14 19:14:42 UTC
Pushed to 3.10.x, will be in 3.10.11
Comment 8 Chris Hall 2013-10-20 07:13:14 UTC
Pushed to 3.8.x, will be in 3.8.19