If your barcodes contain characters like $ (and possible others), it's not possible to use the inventory tool with a barcode file as they will report as 'not scanned', while the datelastseen is still updated. We have a library system that uses barcodes with the following schema: LOCATION_CODE$DIGITS When uploading a file with such barcodes in the inventory tool, they all report as missing. Exceptions are items that are on the wrong place on the shelf, they report correctly. The datelastseen is updated for all items anyway. To test: 1) Create an item with the following barcode: LOC$00001 2) Create a file with the same barcode on the first line. 3) Go to the inventory tool 4) Upload barcode file Check "Compare barcodes list to results" Check "Do not check in items scanned during inventory" Check "Skip items on loan" You might want to pick additional limits for a smaller result set depending on your sample db size, make sure it matches the item catalogued 5) Verify the scanned item is in the list, but the status reads "Missing (not scanned)". I found this regex in the perl code: if( !$barcode ) { $item->{problems}->{no_barcode} = 1; } elsif ( grep /^$barcode$/, @scanned_barcodes ) { next; } else { $item->{problems}->{not_scanned} = 1; } I assume that grep /^$barcode$/ fails because of the unescaped $. Is there a good way to make sure all problematic characters are escaped? Is the grep really necessary here? Later on we make the comparisons differently which is why the "wrongplace" still appears correctly and probably also why the datelastseen is updated as well.
Suggested fix (thx mtj!) } elsif ( grep /^\Q$barcode\E$/, @scanned_barcodes ) {
(In reply to Katrin Fischer from comment #1) > Suggested fix (thx mtj!) > > } elsif ( grep /^\Q$barcode\E$/, @scanned_barcodes ) { https://perldoc.perl.org/functions/quotemeta.html
Also working on bug 22908 (slightly) related in using regexs for separating barcodes.
(In reply to Marcel de Rooy from comment #3) > Also working on bug 22908 (slightly) related in using regexs for separating > barcodes. Oops, bug 22996
A more readable grep would be: } elsif ( grep { $_ eq $barcode } @scanned_barcodes ) {
Will submit a patch.
Created attachment 90188 [details] [review] Bug 23006: Cannot use inventory with barcodes containing special chars If a barcode contains special characters like $, the regex in inventory does no longer work. This fix (as suggested by Jonathan) replaces the regex by a eq compare. Test plan: Pick one barcode and add a $ somewhere in the middle, say 123$456. Include this barcode in a barcode file for inventory. Run inventory on that file and verify that barcode was read and datelastseen was updated. The barcode should not be reported as missing (not scanned). Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Created attachment 90217 [details] [review] Bug 23006: Cannot use inventory with barcodes containing special chars If a barcode contains special characters like $, the regex in inventory does no longer work. This fix (as suggested by Jonathan) replaces the regex by a eq compare. Test plan: Pick one barcode and add a $ somewhere in the middle, say 123$456. Include this barcode in a barcode file for inventory. Run inventory on that file and verify that barcode was read and datelastseen was updated. The barcode should not be reported as missing (not scanned). Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Created attachment 90237 [details] [review] Bug 23006: Cannot use inventory with barcodes containing special chars If a barcode contains special characters like $, the regex in inventory does no longer work. This fix (as suggested by Jonathan) replaces the regex by a eq compare. Test plan: Pick one barcode and add a $ somewhere in the middle, say 123$456. Include this barcode in a barcode file for inventory. Run inventory on that file and verify that barcode was read and datelastseen was updated. The barcode should not be reported as missing (not scanned). Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Thx all!
Nice work! Pushed to master for 19.11.00
Pushed to 19.05.x for 19.05.01
backported to 18.11.x for 18.11.07