Bug 4451 - Batch item tool cannot process barcode file with Windows line endings
Summary: Batch item tool cannot process barcode file with Windows line endings
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Tools (show other bugs)
Version: Main
Hardware: PC All
: PATCH-Sent (DO NOT USE) normal (vote)
Assignee: Owen Leonard
QA Contact: Bugs List
URL: /cgi-bin/koha/tools/batchMod.pl
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-05 12:51 UTC by Owen Leonard
Modified: 2012-10-25 22:52 UTC (History)
1 user (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments
Proposed fix (727 bytes, patch)
2010-07-09 12:49 UTC, Owen Leonard
Details | Diff | Splinter Review
Proposed fix, corrected (728 bytes, patch)
2010-07-09 17:43 UTC, Owen Leonard
Details | Diff | Splinter Review

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