Bug 4451

Summary: Batch item tool cannot process barcode file with Windows line endings
Product: Koha Reporter: Owen Leonard <oleonard>
Component: ToolsAssignee: Owen Leonard <oleonard>
Status: CLOSED FIXED QA Contact: Bugs List <koha-bugs>
Severity: normal    
Priority: PATCH-Sent (DO NOT USE) CC: chris
Version: Main   
Hardware: PC   
OS: All   
URL: /cgi-bin/koha/tools/batchMod.pl
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:
Attachments: Proposed fix
Proposed fix, corrected

Description Chris Cormack 2010-05-21 01:27:21 UTC


---- Reported by oleonard@myacpl.org 2010-05-05 12:51:35 ----

I tried uploading a file of known good barcodes to the batch item modification tool and it reported that the barcodes were not found. Testing shows that the problem was the Windows line endings of the file I was uploading. Re-saving the same file with Unix line endings resulted in a successful read.

Interestingly, the item number file upload is not sensitive to the difference in line endings. Either works.



--- Bug imported by chris@bigballofwax.co.nz 2010-05-21 01:27 UTC  ---

This bug was previously known as _bug_ 4451 at http://bugs.koha.org/cgi-bin/bugzilla3/show_bug.cgi?id=4451

Actual time not defined. Setting to 0.0
Setting qa contact to the default for this product.
   This bug either had no qa contact or an invalid one.

Comment 1 Owen Leonard 2010-07-09 12:46:53 UTC
Some info on IRC from the discussion of Bug 4973:

pianohack > magnus: All chomp does is remove the line ending on the platform you're running on
pianohack > linux server, windows client?
magnus    > yup
magnus    > adding $command_line =~ s/\r//g; solves it
gmcharlt  > s/\r$//g; would be slightly more precise
pianohack > magnus: You might consider just replacing chomp entirely with s/[\r\n]*$//g

Guessing this is the cause of this bug as well I looked for chomp in batchMod.pl:

174            chomp $content;

And changed it based on the pianohack's suggestion:

174            $content = s/[\r\n]*$//g;

This seems to fix the problem.
Comment 2 Owen Leonard 2010-07-09 12:49:29 UTC Comment hidden (obsolete)
Comment 3 Owen Leonard 2010-07-09 17:43:33 UTC
Created attachment 2345 [details] [review]
Proposed fix, corrected

Typo corrected
Comment 4 Chris Cormack 2010-11-30 01:32:40 UTC
Pushed, please test
Comment 5 MJ Ray (software.coop) 2010-12-14 10:23:07 UTC
This bug is mentioned in:
Fix for Bug 4451 Batch item	tool can't process file with Windows line endings http://lists.koha-community.org/pipermail/koha-patches/2010-November/012978.html
bug 4451 followup - don't	need /g for this replace http://lists.koha-community.org/pipermail/koha-patches/2010-November/012979.html