You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
FileSplitterTask produces wrong files: first line lost, line breaks doubled, trailing empty file #205
FileSplitterTask::splitFile() writes lines read with fgets(), which keeps the line break (DROP_NEW_LINE does not apply to fgets()), and SplFile::writeLine() appends PHP_EOL: line breaks are doubled.
FileSplitterTask::next() relies on eof(), which is only true after a read attempt past the last line, so one more (empty) file is produced.
Proposed fix
Open the source without SplFileObject flags and without counting and rewinding, and read one line ahead to know whether another chunk remains.
Write exactly max_lines lines per file (the last one fewer), stripping only the trailing \r\n/\n of each line before writeLine(): no line is lost, content is preserved, line breaks are not doubled.
next() stops as soon as no line is left, so no empty file is emitted; an empty source file is skipped and produces no output.
Update the reference documentation, add unit tests.
Requirements
Documentation updates
Reference
Cookbooks
Changelog
Unit tests
Breaking changes
None: this fixes the content of the produced files (the task was introduced in v5.0, #174). Line breaks in produced files are written as PHP_EOL, and an empty source file now produces no output instead of an empty file.
Activity
Merge pull request #216 from cleverage/205