Closed (fixed)
Project:
Feeds
Version:
7.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
5 Dec 2015 at 21:18 UTC
Updated:
20 Dec 2015 at 21:14 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
megachrizEasy enough to fix. Thanks for the clear bug report!
Comment #3
guypaddock commentedAttached is a better patch that:
- Removes special case handling for "TAB" in all of the places we have it in the CSV parser, moving it to a utility method.
- Also fixes the file extension so that tab-separated CSVs end in TSV so programs like LibreOffice and Excel properly determine the delimiter.
- Moves the list of delimiters used in the Admin UI to one utility method so we have only one place to update if we need to change the delimiters.
Comment #4
guypaddock commentedNoticed a slight style typo, so here's a new version of the previous patch.
Comment #5
megachrizCool! Thanks for improving this.
Code review:
I think that the code is more readable if we leave these function calls at one line (I see that there are no coding standards for this, except discussion: #1539712: [policy, no patch] Coding standards for breaking function calls and language constructs across lines).
Maybe we should change the media type as well for tsv files? According to the wikipedia article about tab-separated values, the media type should be
text/tab-separated-valuesComment #6
megachriz3.
Instead of assigning the value to a variable first, we might as well directly return the value, as nothing else is done with the variable in the rest of the function.
Comment #7
guypaddock commented@MegaChriz: In response to point 1 in #5, this was to address the line length of those calls as the lines were longer than 80 chars:
https://www.drupal.org/coding-standards#linelength
I agree with point 2 in #5. I can make that change.
In response to point 3, this is to enforce a "one entry, one exit" style of coding so it's easier to add debug print statements, breakpoints, etc, as well as to clarify where the function returns:
http://stackoverflow.com/questions/4838828/why-should-a-function-have-on...
Comment #8
guypaddock commentedAttached is a new patch that addresses the following:
- Splits up what was originally a wrapped function call into variables and calls so that we don't have to wrap.
- Replaces
getTemplateExtension()withgetTemplateFileDetails(), which now provides both the file extension and mime type.Comment #9
guypaddock commentedSmall fix for local variable naming style.
Comment #10
guypaddock commentedComment #12
megachriz@GuyPaddock, #7
Thanks for the clarification on point 3. It seem to be a matter of personal preference. I'm okay with it.
I tested the patch in #9 by downloading a template for every delimiter. I also checked the output difference in the code for "TAB" and ",". I looked through the code again and I did not see anything suspicious. All is good. Great function documentation, by the way!
Committed #9.